Skip to content

Commit 85373cd

Browse files
committed
feat: support || expr in where clause for sqlite
1 parent 4b02001 commit 85373cd

3 files changed

Lines changed: 14 additions & 2 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "node-sql-parser",
3-
"version": "3.6.8",
3+
"version": "3.6.9",
44
"description": "simple node sql parser",
55
"main": "index.js",
66
"types": "types.d.ts",

pegjs/sqlite.pegjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1706,7 +1706,7 @@ multiplicative_expr
17061706
}
17071707

17081708
multiplicative_operator
1709-
= "*" / "/" / "%"
1709+
= "*" / "/" / "%" / "||"
17101710

17111711
primary
17121712
= cast_expr

test/sqlite.spec.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,16 @@ describe('sqlite', () => {
2828
author_id;`
2929
expect(getParsedSql(sql)).to.be.equal("SELECT json_extract(`value`, '$.id') AS `author_id` FROM `post`, json_each(`post`.`author`, '$') GROUP BY `author_id`")
3030
})
31+
32+
it('should support || in where clause', () => {
33+
const sql = `SELECT *
34+
FROM
35+
pets
36+
LEFT JOIN(
37+
SELECT * FROM user
38+
WHERE user.name = "pepe" || "rone"
39+
) u ON pets.owner = u.id
40+
GROUP BY pets.id;`
41+
expect(getParsedSql(sql)).to.be.equal("SELECT * FROM `pets` LEFT JOIN (SELECT * FROM `user` WHERE `user`.`name` = 'pepe' || 'rone') AS `u` ON `pets`.`owner` = `u`.`id` GROUP BY `pets`.`id`")
42+
})
3143
})

0 commit comments

Comments
 (0)