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

Function parseCondition

pkg/transform/transform.go:135–147  ·  view source on GitHub ↗

parseCondition parses a SQL condition expression by wrapping it in a SELECT.

(sql string)

Source from the content-addressed store, hash-verified

133
134// parseCondition parses a SQL condition expression by wrapping it in a SELECT.
135func parseCondition(sql string) (ast.Expression, error) {
136 stmt, err := parseSQL("SELECT * FROM _t WHERE " + sql)
137 if err != nil {
138 return nil, fmt.Errorf("parse condition %q: %w", sql, err)
139 }
140
141 sel, ok := stmt.(*ast.SelectStatement)
142 if !ok || sel.Where == nil {
143 return nil, fmt.Errorf("parse condition %q: failed to extract WHERE", sql)
144 }
145
146 return sel.Where, nil
147}
148
149// parseJoinClause parses a JOIN clause from SQL by wrapping it in a SELECT.
150func parseJoinClause(sql string) (*ast.JoinClause, error) {

Callers 2

AddWhereFromSQLFunction · 0.85
parseValueExprFunction · 0.85

Calls 2

parseSQLFunction · 0.70
ErrorfMethod · 0.65

Tested by

no test coverage detected