-
Notifications
You must be signed in to change notification settings - Fork 553
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
Parameterized queries #291
Comments
Thanks @Jasperav . |
I was just going to open an issue about the same thing. Support for other flavors of parameterized queries like |
see discussions in #265 |
I would also be happy to have this feature. |
That issue is closed. Of what use is it? Does that mean that we're decidedly not getting parameter support? |
@git-hulk Hi, and thanks for getting back to this! The current implementation largely works indeed. Unfortunately, it still seems to have a bug that is blocking in my case. I slightly modified one of the cases in the test suite to reproduce it, and – at least in the case of the SQLite dialect – it appears that fn main() {
let ast = sqlparser::parser::Parser::parse_sql(
&sqlparser::dialect::SQLiteDialect {},
"SELECT * FROM student WHERE id = $foo",
);
dbg!(ast);
} prints the following AST (irrelevant parts excluded for clarity):
|
@H2CO3 Thanks for your feedback. This should be caused by
Please refer to: https://www.sqlite.org/draft/tokenreq.html So I guess it should be a bug for the SQLite dialect. I can fix this issue if this change sounds good to you. cc @alamb @iffyio |
Perfect, thanks! |
… SQLite Currently, `$var` would be parsed as an identifier instead of a placeholder in SQLite dialect, which is unexpected from the SQLite's documentation: https://www.sqlite.org/lang_expr.html#varparam. This relates to the issue comment: apache#291 (comment)
@H2CO3 You now can try again. |
This fails to parse, but it can be successfully executed by SQLite (after providing a value for the parameter):
Any idea why I get this error message?:
called
Result::unwrap()
on anErr
value: ParserError("Expected an expression, found: ?")thread 'dynamic_queries::go' panicked at 'called
Result::unwrap()
on anErr
value: ParserError("Expected an expression, found: ?")',The text was updated successfully, but these errors were encountered: