Skip to content

Commit faaf058

Browse files
h3n4lclaude
andcommitted
fix(postgresql): add jsontype rule and fix REVERSE keyword
Fix test failures by adding missing JsonType support and making REVERSE available as a function name. Changes: 1. Add jsontype rule matching PostgreSQL's gram.y: - jsontype: JSON - Added to simpletypename (for general type references) - Added to consttypename (for constant type references) 2. Add REVERSE to plsql_unreserved_keyword: - REVERSE is a PL/pgSQL token but should be usable as a function name - Now matches type_function_name via plsql_unreserved_keyword path Root Cause Analysis: - PostgreSQL's grammar has explicit JsonType rule for JSON keyword - Our grammar was missing this, causing ::json typecast to fail - JSON is a col_name_keyword, not in type_function_name categories - Without jsontype rule, parser tried qualified_name%TYPE_P path - REVERSE was in old builtin_function_name rule (now removed) - After removal, REVERSE token couldn't be used as function name - Solution: Add to plsql_unreserved_keyword to allow SQL usage Test Results: ✅ All previously failing tests now pass: - json_encoding.sql - json.sql - jsonb.sql - join_hash.sql - builtin_functions_string.sql - text.sql ✅ Full test suite passes with no regressions 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent 3859fde commit faaf058

File tree

6 files changed

+14117
-13928
lines changed

6 files changed

+14117
-13928
lines changed

postgresql/PostgreSQLParser.g4

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3194,19 +3194,25 @@ simpletypename
31943194
| character
31953195
| constdatetime
31963196
| constinterval (opt_interval? | OPEN_PAREN iconst CLOSE_PAREN)
3197+
| jsontype
31973198
;
31983199

31993200
consttypename
32003201
: numeric
32013202
| constbit
32023203
| constcharacter
32033204
| constdatetime
3205+
| jsontype
32043206
;
32053207

32063208
generictype
32073209
: (type_function_name | LEFT | RIGHT) attrs? opt_type_modifiers?
32083210
;
32093211

3212+
jsontype
3213+
: JSON
3214+
;
3215+
32103216
opt_type_modifiers
32113217
: OPEN_PAREN expr_list CLOSE_PAREN
32123218
;
@@ -4835,6 +4841,7 @@ plsql_unreserved_keyword
48354841
| RELATIVE_P
48364842
| RESET
48374843
| RETURN
4844+
| REVERSE
48384845
//| RETURNED_SQLSTATE
48394846
| ROLLBACK
48404847
//| ROW_COUNT

0 commit comments

Comments
 (0)