mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-08-25 08:24:05 +00:00
Add support for the MATCH and REGEXP binary operators (#1840)
This commit is contained in:
parent
6cd237ea43
commit
2182f7ea71
4 changed files with 65 additions and 1 deletions
|
@ -562,6 +562,36 @@ fn test_dollar_identifier_as_placeholder() {
|
|||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_match_operator() {
|
||||
assert_eq!(
|
||||
sqlite().verified_expr("col MATCH 'pattern'"),
|
||||
Expr::BinaryOp {
|
||||
op: BinaryOperator::Match,
|
||||
left: Box::new(Expr::Identifier(Ident::new("col"))),
|
||||
right: Box::new(Expr::Value(
|
||||
(Value::SingleQuotedString("pattern".to_string())).with_empty_span()
|
||||
))
|
||||
}
|
||||
);
|
||||
sqlite().verified_only_select("SELECT * FROM email WHERE email MATCH 'fts5'");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_regexp_operator() {
|
||||
assert_eq!(
|
||||
sqlite().verified_expr("col REGEXP 'pattern'"),
|
||||
Expr::BinaryOp {
|
||||
op: BinaryOperator::Regexp,
|
||||
left: Box::new(Expr::Identifier(Ident::new("col"))),
|
||||
right: Box::new(Expr::Value(
|
||||
(Value::SingleQuotedString("pattern".to_string())).with_empty_span()
|
||||
))
|
||||
}
|
||||
);
|
||||
sqlite().verified_only_select(r#"SELECT count(*) FROM messages WHERE msg_text REGEXP '\d+'"#);
|
||||
}
|
||||
|
||||
fn sqlite() -> TestedDialects {
|
||||
TestedDialects::new(vec![Box::new(SQLiteDialect {})])
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue