Skip to content

Commit 038ae49

Browse files
feat(codegen): parse DDL with sqlparser, drop hand-rolled scanner (#38) (#111)
Replace src/codegen/parser.rs's uppercase-and-split scanner with the sqlparser crate (0.50). parse_sql_schema now walks Statement::CreateTable, trying PostgreSQL → SQLite → generic dialects. Public IR (ParsedSchema/TableDef/ColumnDef) and the parse_sql_schema / parse_schema_file signatures are unchanged, so overlay/query consumers are unaffected. split_respecting_parens, parse_create_table and parse_column_def are deleted. Fixes the documented misclassifications: schema-qualified names (bare table identifier extracted), quoted identifiers with whitespace, column- and table-level CHECK clauses (ignored, not split into bogus columns), GENERATED columns, and semicolons inside comments. Invalid SQL is now a hard error instead of a silent empty schema. 6 original parser tests retained + 6 new acceptance tests (schema-qualified, quoted-whitespace, CHECK, GENERATED, semicolon-in-comment, invalid-SQL). Suite: 113 lib + 9 integration green. Closes #38. Co-authored-by: hyperpolymath <hyperpolymath@users.noreply.github.com> Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
1 parent 7a42764 commit 038ae49

3 files changed

Lines changed: 198 additions & 247 deletions

File tree

Cargo.lock

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ thiserror = "2"
2222
chrono = { version = "0.4", features = ["serde"] }
2323
sha2 = "0.10"
2424
rusqlite = { version = "0.32", features = ["bundled", "hooks"] }
25-
tracing = "0.1"
26-
tracing-subscriber = { version = "0.3", features = ["env-filter", "json"] }
25+
sqlparser = "0.50"
2726

2827
[build-dependencies]
2928
chrono = "0.4"

0 commit comments

Comments
 (0)