Add Postgres operators for the LIKE expression variants (#1096)

This commit is contained in:
Marko Grujic 2024-01-22 20:50:29 +01:00 committed by GitHub
parent d72f0a966b
commit c7d2903c6d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 111 additions and 0 deletions

View file

@ -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)