diff --git a/pegjs/sqlite.pegjs b/pegjs/sqlite.pegjs index dc909651..2b0b8077 100644 --- a/pegjs/sqlite.pegjs +++ b/pegjs/sqlite.pegjs @@ -2195,7 +2195,7 @@ regexp_op_right } like_op_right - = op:like_op __ right:(literal / comparison_expr ) __ es:escape_op? { + = op:like_op __ right:(comparison_expr / literal) __ es:escape_op? { if (es) right.escape = es return { op: op, right: right }; } diff --git a/test/sqlite.spec.js b/test/sqlite.spec.js index 31e2cd72..6639ee6a 100644 --- a/test/sqlite.spec.js +++ b/test/sqlite.spec.js @@ -269,6 +269,10 @@ describe('sqlite', () => { const sql = `SELECT * FROM table_name WHERE column_name LIKE '%pattern%' ESCAPE '\'` expect(getParsedSql(sql)).to.be.equal(`SELECT * FROM "table_name" WHERE "column_name" LIKE '%pattern%' ESCAPE '\'`) }) + it('should support string concatenation in LIKE opts', () => { + const sql = `SELECT * FROM file WHERE path LIKE 'C:' || CHAR(92) || 'Users' || CHAR(92) || 'example.txt'` + expect(getParsedSql(sql)).to.be.equal(`SELECT * FROM "file" WHERE "path" LIKE 'C:' || CHAR(92) || 'Users' || CHAR(92) || 'example.txt'`) + }) it('should support GROUP_CONCAT', () => { const sql = `SELECT CASE