diff --git a/pegjs/sqlite.pegjs b/pegjs/sqlite.pegjs index dbd67813..83002589 100644 --- a/pegjs/sqlite.pegjs +++ b/pegjs/sqlite.pegjs @@ -2191,7 +2191,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 83d84aa9..3e95825a 100644 --- a/test/sqlite.spec.js +++ b/test/sqlite.spec.js @@ -253,4 +253,8 @@ describe('sqlite', () => { const sql = `SELECT * FROM table_name WHERE column_name LIKE '\\_%' ESCAPE '\\'` expect(getParsedSql(sql)).to.be.equal(`SELECT * FROM "table_name" WHERE "column_name" LIKE '\\_%' 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'`) + }) })