mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-08-03 22:08:16 +00:00
Support ?-based jsonb operators in Postgres (#1242)
Co-authored-by: Andrew Repp <arepp@cloudflare.com>
This commit is contained in:
parent
bafaa914b0
commit
4aa37a46a9
5 changed files with 125 additions and 13 deletions
|
@ -7802,17 +7802,6 @@ fn test_lock_nonblock() {
|
|||
|
||||
#[test]
|
||||
fn test_placeholder() {
|
||||
let sql = "SELECT * FROM student WHERE id = ?";
|
||||
let ast = verified_only_select(sql);
|
||||
assert_eq!(
|
||||
ast.selection,
|
||||
Some(Expr::BinaryOp {
|
||||
left: Box::new(Expr::Identifier(Ident::new("id"))),
|
||||
op: BinaryOperator::Eq,
|
||||
right: Box::new(Expr::Value(Value::Placeholder("?".into()))),
|
||||
})
|
||||
);
|
||||
|
||||
let dialects = TestedDialects {
|
||||
dialects: vec![
|
||||
Box::new(GenericDialect {}),
|
||||
|
@ -7852,6 +7841,32 @@ fn test_placeholder() {
|
|||
}),
|
||||
);
|
||||
|
||||
let dialects = TestedDialects {
|
||||
dialects: vec![
|
||||
Box::new(GenericDialect {}),
|
||||
Box::new(DuckDbDialect {}),
|
||||
// Note: `?` is for jsonb operators in PostgreSqlDialect
|
||||
// Box::new(PostgreSqlDialect {}),
|
||||
Box::new(MsSqlDialect {}),
|
||||
Box::new(AnsiDialect {}),
|
||||
Box::new(BigQueryDialect {}),
|
||||
Box::new(SnowflakeDialect {}),
|
||||
// Note: `$` is the starting word for the HiveDialect identifier
|
||||
// Box::new(sqlparser::dialect::HiveDialect {}),
|
||||
],
|
||||
options: None,
|
||||
};
|
||||
let sql = "SELECT * FROM student WHERE id = ?";
|
||||
let ast = dialects.verified_only_select(sql);
|
||||
assert_eq!(
|
||||
ast.selection,
|
||||
Some(Expr::BinaryOp {
|
||||
left: Box::new(Expr::Identifier(Ident::new("id"))),
|
||||
op: BinaryOperator::Eq,
|
||||
right: Box::new(Expr::Value(Value::Placeholder("?".into()))),
|
||||
})
|
||||
);
|
||||
|
||||
let sql = "SELECT $fromage_français, :x, ?123";
|
||||
let ast = dialects.verified_only_select(sql);
|
||||
assert_eq!(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue