Skip to content

Commit aced536

Browse files
Merge pull request #2552 from sgress454/sgress454/allow-string-concat-in-like
fix: Support string concatenation in LIKE expressions
2 parents 71372ff + 638d2c3 commit aced536

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

pegjs/sqlite.pegjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2195,7 +2195,7 @@ regexp_op_right
21952195
}
21962196

21972197
like_op_right
2198-
= op:like_op __ right:(literal / comparison_expr ) __ es:escape_op? {
2198+
= op:like_op __ right:(comparison_expr / literal) __ es:escape_op? {
21992199
if (es) right.escape = es
22002200
return { op: op, right: right };
22012201
}

test/sqlite.spec.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,10 @@ describe('sqlite', () => {
269269
const sql = `SELECT * FROM table_name WHERE column_name LIKE '%pattern%' ESCAPE '\'`
270270
expect(getParsedSql(sql)).to.be.equal(`SELECT * FROM "table_name" WHERE "column_name" LIKE '%pattern%' ESCAPE '\'`)
271271
})
272+
it('should support string concatenation in LIKE opts', () => {
273+
const sql = `SELECT * FROM file WHERE path LIKE 'C:' || CHAR(92) || 'Users' || CHAR(92) || 'example.txt'`
274+
expect(getParsedSql(sql)).to.be.equal(`SELECT * FROM "file" WHERE "path" LIKE 'C:' || CHAR(92) || 'Users' || CHAR(92) || 'example.txt'`)
275+
})
272276
it('should support GROUP_CONCAT', () => {
273277
const sql = `SELECT
274278
CASE

0 commit comments

Comments
 (0)