-
Notifications
You must be signed in to change notification settings - Fork 572
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add conditional compilation to support different SQL dialect #207
Comments
You're right that every dialect of SQL is different. Currently (until the dialects story is figured out in #7) we deal with this by accepting dialect-specific extensions in the mainline parser -- with tests and an indication which dialects an extension applies to, but no toggle to select a dialect. Sometimes we come up with a generic grammar that the common dialects fit (e.g. ColumnOptionDef). Why do you bring that up? Are you planning to work on something where this approach doesn't work well? Can you share the details? My thoughts on this: Dialect-specific parsing is required to properly handle cases where grammars of different dialects are in conflict with each other. I can think of two ideas we'll need to combine:
Given that one of the use-cases for the parser is tooling (e.g. @maxcountryman's A reason to select a dialect at build time, assuming there already is a run-time switch, as I understand it, is to work with a simpler AST without having to write lots of repetitive code to reject constructs you don't support. Under this assumption it makes more sense for downstream consumers to define their AST types, and for the library to provide a way to do so (I touched on that in #189), rather than providing a limited number of pre-defined dialects as "features". |
I use sqlparser-rs to parse SQLite's SQL statements. Here is SQLite's CREATE TABLE grammar SQLite CREATE TABLE. It supports |
sqlite's As I recently noted in an another discussion with @Dandandan, we could change
|
I add |
@alamb can we close this? Doesn't seem active for a while. |
👍 please reopen if there is more to say (or feel free to file a new issue too) |
The SQL dialect of the database is different, like when you use
CREATE TABLE
, if you use SQLite, maybe you don't want to use the crowd, you can write SQL like thisCREATE TABLE test ( a TEXT )WITHOUT ROWID;
,but MySQL or PostgresSQL don't support that, if you use MySQL, you can choose the storage engine like
CREATE TABLE test( a varchar(100) ) ENGINE=InnoDB;
.So, we can add features like
cargo build --features "sqlite"
that will support SQLite grammars.The text was updated successfully, but these errors were encountered: