mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-08-23 15:34:09 +00:00
Add Postgres operators for the LIKE expression variants (#1096)
This commit is contained in:
parent
d72f0a966b
commit
c7d2903c6d
4 changed files with 111 additions and 0 deletions
|
@ -1804,6 +1804,28 @@ fn parse_pg_regex_match_ops() {
|
|||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_pg_like_match_ops() {
|
||||
let pg_like_match_ops = &[
|
||||
("~~", BinaryOperator::PGLikeMatch),
|
||||
("~~*", BinaryOperator::PGILikeMatch),
|
||||
("!~~", BinaryOperator::PGNotLikeMatch),
|
||||
("!~~*", BinaryOperator::PGNotILikeMatch),
|
||||
];
|
||||
|
||||
for (str_op, op) in pg_like_match_ops {
|
||||
let select = pg().verified_only_select(&format!("SELECT 'abc' {} 'a_c%'", &str_op));
|
||||
assert_eq!(
|
||||
SelectItem::UnnamedExpr(Expr::BinaryOp {
|
||||
left: Box::new(Expr::Value(Value::SingleQuotedString("abc".into()))),
|
||||
op: op.clone(),
|
||||
right: Box::new(Expr::Value(Value::SingleQuotedString("a_c%".into()))),
|
||||
}),
|
||||
select.projection[0]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_array_index_expr() {
|
||||
let num: Vec<Expr> = (0..=10)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue