-
Notifications
You must be signed in to change notification settings - Fork 558
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 IN ()
syntax of SQLite
#1005
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 for the contribution @lewiszlw -- this looks good to me other than the renaming of parse_comma_separated1
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 for the contribution as well as the testing @lewiszlw
It appears there are some CI on this PR |
IN ()
syntax of SQLite
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.
Hi @lewiszlw -- thank you for this PR.
I was going through it and I don't fully understand all the code in parse_comma_separated0
Using the following version, the tests/sqlparser_sqlite.rs
test passes (though some of the unit tests do not)
Can you please add tests in tests/sqlparser_sqlite.rs
that show what this extra code is doing / what types of queries it is parsing?
/// Parse a comma-separated list of 0+ items accepted by `F`
pub fn parse_comma_separated0<T, F>(&mut self, f: F) -> Result<Vec<T>, ParserError>
where
F: FnMut(&mut Parser<'a>) -> Result<T, ParserError>,
{
if matches!(self.peek_token().token, Token::RParen)
{
return Ok(vec![])
}
self.parse_comma_separated(f)
}
Great ! Can we make a new release after that ? |
@alamb Sorry for late.
My latest code works for case2. If your code changed like this, then also works for case2
|
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 again for your contribution @lewiszlw
I am worried that this PR may have unintended side effects of parsing comma separated values which is critical functionality for sqlparser.
Thus I would like to request we keep this change simpler and thus less likely to cause unintended consequences.
Here is an alternate proposal: #1028
} | ||
|
||
sqlite_with_options(ParserOptions::new().with_trailing_commas(true)).one_statement_parses_to( | ||
"SELECT * FROM t1 WHERE a IN (,)", |
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.
FWIW this doesn't appear to be valid SQLite syntax:
sqlite> create table t as values (1);
sqlite> select * from t where column1 IN (,);
Parse error: near ",": syntax error
select * from t where column1 IN (,);
error here ---^
Close in favor of #1028 |
SQLite3 supports in empty list expression.