Skip to content
This repository was archived by the owner on Nov 22, 2018. It is now read-only.

Commit b2e4645

Browse files
author
Jan Mercl
committed
Fix precedence of the LIKE operator.
1 parent de57889 commit b2e4645

File tree

7 files changed

+260
-204
lines changed

7 files changed

+260
-204
lines changed

doc.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -673,8 +673,8 @@
673673
// Expression = Term { oror Term } .
674674
//
675675
// ExpressionList = Expression { "," Expression } [ "," ].
676-
// Factor = PrimaryFactor { ( ge | ">" | le | "<" | neq | eq ) PrimaryFactor } [ Predicate ] .
677-
// PrimaryFactor = PrimaryTerm { ( "^" | "|" | "-" | "+" | "LIKE" ) PrimaryTerm } .
676+
// Factor = PrimaryFactor { ( ge | ">" | le | "<" | neq | eq | "LIKE" ) PrimaryFactor } [ Predicate ] .
677+
// PrimaryFactor = PrimaryTerm { ( "^" | "|" | "-" | "+" ) PrimaryTerm } .
678678
// PrimaryTerm = UnaryExpr { ( andnot | "&" | lsh | rsh | "%" | "/" | "*" ) UnaryExpr } .
679679
// Term = Factor { andand Factor } .
680680
// UnaryExpr = [ "^" | "!" | "-" | "+" ] PrimaryExpression .

expr.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ func (p *pLike) eval(ctx map[interface{}]interface{}, arg []interface{}) (v inte
182182

183183
sexpr, ok = expr.(string)
184184
if !ok {
185-
return nil, fmt.Errorf("non-string expression: %v (value of type %T)", expr, expr)
185+
return nil, fmt.Errorf("non-string expression in LIKE: %v (value of type %T)", expr, expr)
186186
}
187187

188188
if p.expr.isStatic() {
@@ -204,7 +204,7 @@ func (p *pLike) eval(ctx map[interface{}]interface{}, arg []interface{}) (v inte
204204

205205
spattern, ok := pattern.(string)
206206
if !ok {
207-
return nil, fmt.Errorf("non-string expression: %v (value of type %T)", pattern, pattern)
207+
return nil, fmt.Errorf("non-string pattern in LIKE: %v (value of type %T)", pattern, pattern)
208208
}
209209

210210
if re, err = regexp.Compile(spattern); err != nil {

0 commit comments

Comments
 (0)