MCPcopy Create free account
hub / github.com/ajitpratap0/GoSQLX / parseValueExpr

Function parseValueExpr

pkg/transform/set.go:36–45  ·  view source on GitHub ↗

parseValueExpr parses a SQL value expression string using the "SELECT * FROM _t WHERE _col = " trick, returning the right-hand side of the equality. This handles literals, function calls, identifiers, etc.

(valueSQL string)

Source from the content-addressed store, hash-verified

34// "SELECT * FROM _t WHERE _col = <valueSQL>" trick, returning the right-hand
35// side of the equality. This handles literals, function calls, identifiers, etc.
36func parseValueExpr(valueSQL string) (ast.Expression, error) {
37 expr, err := parseCondition(fmt.Sprintf("_col = %s", valueSQL))
38 if err != nil {
39 return nil, fmt.Errorf("parse value %q: %w", valueSQL, err)
40 }
41 if bin, ok := expr.(*ast.BinaryExpression); ok {
42 return bin.Right, nil
43 }
44 return expr, nil
45}
46
47// AddSetClause returns a Rule that appends a new assignment to the SET clause
48// of an UPDATE statement. If a column with the same name already exists (case-

Callers 2

AddSetClauseFunction · 0.85
ReplaceSetClauseFunction · 0.85

Calls 2

parseConditionFunction · 0.85
ErrorfMethod · 0.65

Tested by

no test coverage detected