isaacparker0 commented on code in PR #2168:
URL:
https://github.com/apache/datafusion-sqlparser-rs/pull/2168#discussion_r2742301824
##########
src/parser/mod.rs:
##########
@@ -9002,7 +9002,15 @@ impl<'a> Parser<'a> {
/// [ColumnOption::NotNull].
fn parse_column_option_expr(&mut self) -> Result<Expr, ParserError> {
if self.peek_token_ref().token == Token::LParen {
- let expr: Expr = self.with_state(ParserState::Normal, |p|
p.parse_prefix())?;
+ let mut expr = self.with_state(ParserState::Normal, |p|
p.parse_prefix())?;
Review Comment:
That change would fix the bug here, but break the behavior added in
https://github.com/apache/datafusion-sqlparser-rs/pull/1927. In Normal state,
`NOT NULL` is treated as an expression (i.e., `IS NOT NULL`), but in
ColumnDefinition state it's not, allowing the trailing `NOT NULL` to be parsed
as a column constraint instead.
My proposed change is basically just duplicating part of the existing logic
used in `parse_subexpr`[^1]. If we run `parse_prefix` in normal state but the
infix loop in ColumnDefinition state, we maintain the NOT NULL parsing behavior
added in the previous PR but still properly handle infix operators like
`::TEXT`.
I'm still familiarizing myself with this repo, so there may be a better way
to do this, but this is what I've come up with so far and why it seems like the
right approach to me.
Also happy to do a bit of refactoring to cleanly extract a single shared
logic for the part of `parse_subexpr` that we are duplicating if that seems
preferable.
[^1]:
https://github.com/apache/datafusion-sqlparser-rs/blob/62cf16f3ece6f3d5985e35893407c8db359ffd3f/src/parser/mod.rs#L1337-L1363
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]