Skip to content

Commit a0a3a5a

Browse files
committed
Merge branch 'patch-0.38.2'
2 parents 721674c + 1791d83 commit a0a3a5a

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "sql-parser-cst",
33
"description": "Parses SQL into Concrete Syntax Tree (CST)",
44
"license": "GPL-2.0-or-later",
5-
"version": "0.38.1",
5+
"version": "0.38.2",
66
"main": "lib/main.js",
77
"types": "lib/main.d.ts",
88
"repository": {

src/parser.pegjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9062,7 +9062,7 @@ bignumeric_literal
90629062

90639063
interval_literal
90649064
= (&bigquery / &mysql / &postgres)
9065-
kw:(INTERVAL __) precision:(paren$number_literal __)? value:expr
9065+
kw:(INTERVAL __) precision:(paren$number_literal __)? value:sub_comparison_expr
90669066
unit:(__ (interval_unit_range / interval_unit))? {
90679067
return loc({
90689068
type: "interval_literal",

test/literal/interval.test.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,12 @@ describe("INTERVAL literal", () => {
4949
testExpr(`INTERVAL -3 DAY`);
5050
testExpr(`INTERVAL delay + ship_time DAY`);
5151
});
52+
53+
// Regression test for: https://github.com/nene/prettier-plugin-sql-cst/issues/60
54+
it("does not support boolean and comparison expressions in the INTERVAL expression", () => {
55+
expect(parseExpr(`INTERVAL 3 AND 5`).type).toBe("binary_expr");
56+
expect(parseExpr(`INTERVAL 3 > 5`).type).toBe("binary_expr");
57+
});
5258
});
5359

5460
dialect(["mysql", "mariadb"], () => {

0 commit comments

Comments
 (0)