mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-08-30 10:47:22 +00:00
Fix parse error on some prepared statement placeholders (#604)
sqlparser can now parse all the prepared statement placeholders supported by SQLite: - ? - ?NNN - @VVV - :VVV - $VVV See: https://www.sqlite.org/lang_expr.html#varparam This does not break existing support for postgresql's '@' operator Fixes #603
This commit is contained in:
parent
3ac1bb5b80
commit
604f755a59
4 changed files with 45 additions and 12 deletions
|
@ -22,6 +22,7 @@
|
|||
mod test_utils;
|
||||
|
||||
use matches::assert_matches;
|
||||
use sqlparser::ast::SelectItem::UnnamedExpr;
|
||||
use sqlparser::ast::*;
|
||||
use sqlparser::dialect::{
|
||||
AnsiDialect, BigQueryDialect, ClickHouseDialect, GenericDialect, HiveDialect, MsSqlDialect,
|
||||
|
@ -5299,6 +5300,17 @@ fn test_placeholder() {
|
|||
rows: OffsetRows::None,
|
||||
}),
|
||||
);
|
||||
|
||||
let sql = "SELECT $fromage_français, :x, ?123";
|
||||
let ast = dialects.verified_only_select(sql);
|
||||
assert_eq!(
|
||||
ast.projection,
|
||||
vec![
|
||||
UnnamedExpr(Expr::Value(Value::Placeholder("$fromage_français".into()))),
|
||||
UnnamedExpr(Expr::Value(Value::Placeholder(":x".into()))),
|
||||
UnnamedExpr(Expr::Value(Value::Placeholder("?123".into()))),
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue