Repository navigation
SQLite: Support multi-word type names - #2556
LucaCappelletti94 wants to merge 7 commits into
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2556 +/- ##
==========================================
+ Coverage 81.99% 82.03% +0.03%
==========================================
Files 42 42
Lines 35049 35129 +80
Branches 35049 35129 +80
==========================================
+ Hits 28740 28817 +77
- Misses 2744 2747 +3
Partials 3565 3565 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
295fab0 to
d53faf5
Compare
d53faf5 to
b037052
Compare
sabir-akhadov-localstack
left a comment
There was a problem hiding this comment.
Two non-blocking comments inline.
| Ok(DataType::TsQuery) | ||
| } | ||
| _ => { | ||
| if self.dialect.supports_multiword_type_names() { |
There was a problem hiding this comment.
Types with a dedicated arm never reach this path, so CREATE TABLE t (a INT FOO) and a TEXT FOO PRIMARY KEY still fail on SQLite while a FOO INT parses; sqlite 3.46 accepts both and stores the declared type as INT FOO. Rewinding to next_token_index and taking parse_multiword_type_name when the token after the dedicated arm would continue the name covers it.
There was a problem hiding this comment.
Built-in-prefixed type names are handled in 947dab70. The fallback covers both remaining name words and errors inside dedicated parsers, including ENUM FOO and TIMESTAMP WITH FOO.
| ), | ||
| _ => true, // e.g. comma immediately after column name | ||
| // A single-quoted string is a valid type name in SQLite's ids grammar. | ||
| Token::SingleQuotedString(_) => false, |
There was a problem hiding this comment.
CREATE TABLE t (a NULL, b INT) is an untyped column with a NULL constraint in sqlite 3.46 (pragma_table_info type is empty) but parses here as Custom(NULL); Keyword::NULL is missing from this list although the continuation stop set in parse_multiword_type_name has it.
There was a problem hiding this comment.
Leading NULL is parsed as a constraint on an untyped column in 947dab70, and I added adequate tests for the rejected variants.
947dab7 to
d30b486
Compare
d30b486 to
68b01b4
Compare
This PR lets
SQLiteDialectparse type names made of several words or string literals in column definitions,CASTandALTER TABLE ... ADD. Column constraints such asNOT NULL,PRIMARY KEYorDEFAULTstill end the type name.SQLite accepts any sequence of names as a type, see datatypes.