Skip to content

feat: parse SQLite WITHOUT ROWID and STRICT table options - #2903

Open
chinmayajha wants to merge 1 commit into
JSQLParser:masterfrom
chinmayajha:sqlite-without-rowid-strict
Open

chinmayajha wants to merge 1 commit into
JSQLParser:masterfrom
chinmayajha:sqlite-without-rowid-strict

Conversation

@chinmayajha

Copy link
Copy Markdown

Part of #2852 (the WITHOUT ROWID and STRICT part; INSERT OR is in #2853 and UPDATE OR is in #2885).

SQLite takes a comma-separated list of table options after the column list (lang_createtable). Neither option parses:

CREATE TABLE t (a INTEGER PRIMARY KEY, b TEXT) WITHOUT ROWID
-- Expected OIDS but found ROWID
CREATE TABLE t (a INTEGER PRIMARY KEY, b TEXT) STRICT
-- Encountered: <K_STRICT> / "STRICT"

CreateTableOption() now reads WITHOUT ROWID before the existing WITHOUT OIDS branch, and STRICT as its own option. Both get a TableOption.Kind (WITHOUT_ROWID, STRICT). SQLite needs the comma in WITHOUT ROWID, STRICT (sqlite3 rejects WITHOUT ROWID STRICT), but appendTableOptionsTo joins options with a space, so it now writes , between two of these options and a space everywhere else. MySQL options print as before.

SQLiteTest covers each option, both orders and lower case, and checks the parsed kinds. Other uses of STRICT and WITHOUT (ClickHouse EXCEPT STRICT/REPLACE STRICT, function STRICT, STRICT as a name, WITHOUT OIDS, WITHOUT TIME ZONE) round-trip the same as on master. gradle check passes (on JDK 26, by overriding the 17 toolchain locally), and checkGrammarAmbiguity reports no warnings.

I used Claude to help write this, and I checked the change and the tests.

SQLite takes a comma-separated list of WITHOUT ROWID and STRICT after the column list. Both are now TableOption kinds, and the deparser keeps the comma SQLite requires between them.

Part of JSQLParser#2852

This branch has not been deployed

No deployments
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