Skip to content

Commit 285afe7

Browse files
committed
Merge branch 'DBTOOLS-1822_fix_pg_parser' into 'master'
DBTOOLS-1822 fixed pg parser See merge request codekeeper/pgcodekeeper-core!105
2 parents aa513fd + 550c726 commit 285afe7

File tree

5 files changed

+23
-1
lines changed

5 files changed

+23
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1515

1616
- Improved parser rules for ClickHouse.
1717
- Improved migration script generation for tables and indexes with options in MS SQL.
18+
- Added the IS JSON parser rule for PostgreSQL.
1819

1920
### Fixed
2021

CHANGELOG.ru.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
- Улучшены правила парсера для ClickHouse.
1717
- Улучшена генерация скрипта миграции для таблиц и индексов с опциями в MS SQL.
18+
- Добавлено правило парсера IS JSON для PostgreSQL.
1819

1920
### Исправлено
2021

src/main/antlr4/org/pgcodekeeper/core/parsers/antlr/pg/generated/SQLParser.g4

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3489,6 +3489,7 @@ vex
34893489
| vex IS NOT? OF LEFT_PAREN type_list RIGHT_PAREN
34903490
| vex ISNULL
34913491
| vex NOTNULL
3492+
| vex IS NOT? JSON (VALUE | SCALAR | ARRAY | OBJECT)? ((WITH | WITHOUT) UNIQUE KEYS?)?
34923493
| <assoc=right> NOT vex
34933494
| vex AND vex
34943495
| vex OR vex

src/test/resources/org/pgcodekeeper/core/it/parser/pg/select.sql

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1441,3 +1441,19 @@ COLUMNS (
14411441
COLUMNS (
14421442
author_id FOR ORDINALITY,
14431443
author_name text PATH '$.name'))));
1444+
1445+
SELECT js,
1446+
js IS JSON "json?",
1447+
js IS JSON SCALAR "scalar?",
1448+
js IS JSON OBJECT "object?",
1449+
js IS JSON ARRAY "array?"
1450+
FROM (VALUES
1451+
('123'), ('"abc"'), ('{"a": "b"}'), ('[1,2]'),('abc')) foo(js);
1452+
SELECT js,
1453+
js IS JSON OBJECT "object?",
1454+
js IS JSON ARRAY "array?",
1455+
js IS JSON ARRAY WITH UNIQUE KEYS "array w. UK?",
1456+
js IS JSON ARRAY WITHOUT UNIQUE KEYS "array w/o UK?"
1457+
FROM (VALUES ('[{"a":"1"},
1458+
{"b":"2","b":"3"}]')) foo(js);
1459+
SELECT _txt IS JSON;

src/test/resources/org/pgcodekeeper/core/it/parser/pg/select_refs.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1112,4 +1112,7 @@ Reference: action = SELECT, offset = 86717, line number = 1415, charPositionInLi
11121112
Reference: action = SELECT, offset = 86785, line number = 1416, charPositionInLine = 0
11131113
Reference: action = SELECT, offset = 86888, line number = 1417, charPositionInLine = 0
11141114
Reference: action = SELECT, offset = 86955, line number = 1418, charPositionInLine = 0
1115-
Reference: action = SELECT, offset = 87054, line number = 1420, charPositionInLine = 0
1115+
Reference: action = SELECT, offset = 87054, line number = 1420, charPositionInLine = 0
1116+
Reference: action = SELECT, offset = 87780, line number = 1445, charPositionInLine = 0
1117+
Reference: action = SELECT, offset = 87986, line number = 1452, charPositionInLine = 0
1118+
Reference: action = SELECT, offset = 88223, line number = 1459, charPositionInLine = 0

0 commit comments

Comments
 (0)