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
Right now `sqlparser-rs` inject the `AS` keyword in front of aliases
unconditionally. As reported by #1875 or #1784 this leads to problems on
Oracle databases. This patch preserves the original absence / presence of the
keyword (implicit/explicit aliases) in "table-factor" position when rendered
via `Display`.
1. Some more effort could be invested to apply the same behavior for
`SelectItem`s (ie. projections in queries) and further nodes of the AST with
an alias for which `AS` is optional. To unify the implementation within the
parser and for clients, representing aliases could then be exposed not as pure
`Ident`s but maybe as something as:
```rust
struct Alias {
explicit: bool,
name: Ident,
}
impl Deref for Alias {
type Target = Ident;
...
}
impl From<Alias> for Ident {
...
}
```
2. The parser could be instructed / configured (either by ParserOptions or
through a Dialect setting) to always produce "explicit" alias tokens. This
would then always produce the `AS` keyword when render via `Display`. Ideally,
there would be a `VisitorMut::visit_(mut_)alias` and clients could easily apply
their own preference.
3. I'd greatly appreciate a critical look since my know-how regarding
different DBs is quite limited. I hope I've not broken any of the existing
dialects and also hope this PR helps "preserving the syntax round trip".
0 commit comments