You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 dialect_of!(parser is Dialect1 | Dialect2 | GenericDialect) helper was introduced in #254 to let the parser branch on the dialect's type. An example where such branching is required is when the grammars of various dialects conflict, e.g. #241 (comment)
I do prefer branching on specific dialects in the parser to adding flags (like is_standard_trim_supported / is_non_standard_trim_supported in your example) to the dialect trait and I do not understand what problem you are having with dialect_of!.
@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?
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.
Activity
ever0de commentedon Aug 25, 2021
E.g
PostgreSQL
MySQL
Sqlite
ever0de commentedon Aug 25, 2021
There was an issue related to this
After some more thought, how about managing Dialect with features?
ever0de commentedon Aug 25, 2021
Ast Display should also be considered.
Looks like this should be a different issue.
nickolay commentedon Dec 12, 2021
The
dialect_of!(parser is Dialect1 | Dialect2 | GenericDialect)helper was introduced in #254 to let the parser branch on the dialect's type. An example where such branching is required is when the grammars of various dialects conflict, e.g. #241 (comment)I do prefer branching on specific dialects in the parser to adding flags (like
is_standard_trim_supported/is_non_standard_trim_supportedin your example) to the dialect trait and I do not understand what problem you are having withdialect_of!.AugustoFKL commentedon Oct 1, 2022
@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.,
nickolay commentedon Oct 1, 2022
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.
ever0de commentedon Oct 1, 2022
I understood this answer.
Please close the issue when the discussion is over, Thanks!
AugustoFKL commentedon Oct 1, 2022
@nickolay makes sense, thanks!
LucaCappelletti94 commentedon Sep 23, 2026
Closing as the discussion has concluded.