AddWhereFromSQL returns a Rule that parses a SQL condition string and adds it as an AND condition to the existing WHERE clause. WARNING: sql parameter must not contain untrusted user input. This function parses raw SQL - passing unsanitized input could produce unintended query modifications. Use pa
(sql string)
| 107 | // produce unintended query modifications. Use parameterized queries |
| 108 | // or construct AST nodes directly for untrusted input. |
| 109 | func AddWhereFromSQL(sql string) Rule { |
| 110 | return RuleFunc(func(stmt ast.Statement) error { |
| 111 | condition, err := parseCondition(sql) |
| 112 | if err != nil { |
| 113 | return err |
| 114 | } |
| 115 | return AddWhere(condition).Apply(stmt) |
| 116 | }) |
| 117 | } |