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)
| 34 | // "SELECT * FROM _t WHERE _col = <valueSQL>" trick, returning the right-hand |
| 35 | // side of the equality. This handles literals, function calls, identifiers, etc. |
| 36 | func 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- |
no test coverage detected