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
Support MySQL ROWS
syntax for VALUES
#737
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @aljazerzen
The code and tests look good except for the within_insert
special case
src/parser.rs
Outdated
if parser.parse_keyword(Keyword::ROW) { | ||
explicit_row = true; | ||
} else { | ||
if !within_insert && parser.dialect.values_require_row_in_select() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How important is it to reject the ROWS keyword during inserts? I see that mySQL is not consistent in that ROW is not allowed in INSERT statements https://dev.mysql.com/doc/refman/8.0/en/insert.html
However, I also don't see any (negative) tests for this case in this PR, though maybe I have missed them
My preference is to remove the special case handling for in select and make the parser permissive and support an optional ROW whenever a VALUES list is specified.
Downstream crates that care can detect explicit_row
and error if they don't want to allow that syntax.
We tried to make the philosophy of "parse all the things" clearer recently in the introduction here https://github.com/sqlparser-rs/sqlparser-rs#extensible-sql-lexer-and-parser-for-rust
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BTW I found
Quality of my code reflects banality of this detail.
😆
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah that makes sense - there is no need to inforce explict row. And it simplifies the code a lot!
Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org>
Pull Request Test Coverage Report for Build 3590726471
💛 - Coveralls |
ROWS
syntax for VALUES
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good -- thank you @aljazerzen
MySQL does not support following query:
... but supports ...
https://dev.mysql.com/doc/refman/8.0/en/values.html
Note that is does support:
Quality of my code reflects banality of this detail.