Skip to content

Commit 85f0678

Browse files
sgress454taozhi8833998
authored andcommitted
Add "ESCAPE" support to "LIKE" for sqlite
1 parent 80d93c7 commit 85f0678

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

pegjs/sqlite.pegjs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2172,6 +2172,16 @@ regexp_op
21722172
= n: KW_NOT? __ k:(KW_REGEXP / KW_RLIKE) {
21732173
return n ? `${n} ${k}` : k
21742174
}
2175+
2176+
escape_op
2177+
= kw:'ESCAPE'i __ c:literal_string {
2178+
// => { type: 'ESCAPE'; value: literal_string }
2179+
return {
2180+
type: 'ESCAPE',
2181+
value: c,
2182+
}
2183+
}
2184+
21752185
in_op
21762186
= nk:(KW_NOT __ KW_IN) { return nk[0] + ' ' + nk[2]; }
21772187
/ KW_IN
@@ -2185,7 +2195,8 @@ regexp_op_right
21852195
}
21862196

21872197
like_op_right
2188-
= op:like_op __ right:(literal / comparison_expr) {
2198+
= op:like_op __ right:(literal / comparison_expr ) __ es:escape_op? {
2199+
if (es) right.escape = es
21892200
return { op: op, right: right };
21902201
}
21912202

0 commit comments

Comments
 (0)