Skip to content

Update reserved words list, add more join support#3

Open
sgress454 wants to merge 5 commits into
masterfrom
sgress454/35762-update-reserved-words-list
Open

Update reserved words list, add more join support#3
sgress454 wants to merge 5 commits into
masterfrom
sgress454/35762-update-reserved-words-list

Conversation

@sgress454

@sgress454 sgress454 commented Dec 2, 2025

Copy link
Copy Markdown
Owner

This PR updates the list of reserved words that cannot be used unquoted as identifiers. The list was generated using a C program that iterates over the full set of keywords in SQLite and attempts to do CREATE TABLE t(<keyword> INTEGER); for each one, tracking which keywords fail. Many words that were previously in the reservedMap passed this test and have been removed.

Removing items from that list prompted a bit of yak shaving:

  • The alias_ident rule has been split into alias_ident_explicit (i.e. using AS) and alias_ident_implicit (not using AS, e.g. SELECT * FROM foo bar WHERE bar.val = 1).
  • A new invalidImplicitAliasMap is added (generated using the same C program) to track which keywords cannot be used as implicit aliases. There's a lot of overlap with reserveredMap, but there are items exclusive to both lists.
  • More joins have been implemented. RIGHT joins were previously incorrectly parsed as aliases because the join_op rule didn't implement them, but now they were broken entirely, so I went ahead and implemented them + other missing joins.
  • Added tests for all joins
  • The alter_table_stmt rule now only supports one table name (which is correct for SQLite), as the previous rule was not compatible with the alias rule updates. That rule used table_ref_list which supports aliases for table names, which caused the parser to interpret things like RENAME as table aliases. Aliases are not valid in ALTER TABLE statements.

Resolves conflict in test/sqlite.spec.js by keeping both sets of
non-overlapping tests: the branch's keyword/reserved-word, alias, and
join tests alongside master's CTE-with-VALUES and IN-clause tests.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant