From 250b7424150b2647096a727062ff05561e01b4f4 Mon Sep 17 00:00:00 2001 From: Scott Gress Date: Mon, 25 Aug 2025 09:50:48 -0500 Subject: [PATCH] support concat in like expressions --- pegjs/sqlite.pegjs | 2 +- test/sqlite.spec.js | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/pegjs/sqlite.pegjs b/pegjs/sqlite.pegjs index 8724e62a..0b0e9c54 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 dda7d384..185cd697 100644 --- a/test/sqlite.spec.js +++ b/test/sqlite.spec.js @@ -269,4 +269,8 @@ 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'`) + }) })