-
Notifications
You must be signed in to change notification settings - Fork 567
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
[Discussion] Remove use of dialect_of
macro
#339
Comments
E.g
fn is_delimited_identifier_start(&self, ch: char);
fn is_identifier_start(&self, ch: char) -> bool;
fn is_identifier_part(&self, ch: char) -> bool;
...
fn is_standard_trim_supported(..) -> bool {
// e.g. TRIM(LEADING FROM "ABC")
true
}
fn is_non_standard_trim_supported(..) -> bool {
// e.g. TRIM("ABC", "A");
true
}
} PostgreSQLMySQLSqlite |
There was an issue related to this After some more thought, how about managing Dialect with features? |
Ast Display should also be considered. |
The I do prefer branching on specific dialects in the parser to adding flags (like |
@nickolay can't we have a default implementation for stuff that is generic, i.e., is specified on the ANSII, and specific implementation overwriting them if the child ever needs it? E.g., impl GenericDialect {
fn parse_limit() {
#fail
}
}
impl MySqlDialect {
fn parse_limit() {
#specific implementation
}
} |
You could technically do that, but why? Current design aims to produce a parser that’s able to parse SQL from common dialects with minimal maintenance effort. Producing “strict” dialect-specific parsers, that reject syntax not supported by the given dialect, would require maintaining a separate parser for each dialect — so it isn’t a goal of this project. One can fork and remove the unneeded code if they need a strict parser. Note that the “generic” dialect accepts as much dialect specific stuff as possible; not the “lowest common denominator” dialect, and not the ANSI dialect, as you think. So with the approach you suggested, we’d have two copies of all dialect-specific code: one in the dialect-specific trait and another in the generic trait. With that in mind, and given that all trait implementations must return the same AST type, in most cases branching on the dialect in the shared parser code just seems to make more sense. |
I understood this answer. |
@nickolay makes sense, thanks! |
What was the purpose of the current
Dialect
?The
dialect_of
macro makes it difficult to modify your code whenever you add support for Dialect.And besides the identifier support of Dialect, it seems that it can also support query (Expr).
But... if you have other intentions for macros
Since there is a problem, I would like to discuss it with the maintainers.
The text was updated successfully, but these errors were encountered: