mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-08-31 03:07:20 +00:00
Add support for NULL escape char in pattern match searches (#1913)
Some checks are pending
license / Release Audit Tool (RAT) (push) Waiting to run
Rust / codestyle (push) Waiting to run
Rust / lint (push) Waiting to run
Rust / benchmark-lint (push) Waiting to run
Rust / compile (push) Waiting to run
Rust / docs (push) Waiting to run
Rust / compile-no-std (push) Waiting to run
Rust / test (beta) (push) Waiting to run
Rust / test (nightly) (push) Waiting to run
Rust / test (stable) (push) Waiting to run
Some checks are pending
license / Release Audit Tool (RAT) (push) Waiting to run
Rust / codestyle (push) Waiting to run
Rust / lint (push) Waiting to run
Rust / benchmark-lint (push) Waiting to run
Rust / compile (push) Waiting to run
Rust / docs (push) Waiting to run
Rust / compile-no-std (push) Waiting to run
Rust / test (beta) (push) Waiting to run
Rust / test (nightly) (push) Waiting to run
Rust / test (stable) (push) Waiting to run
This commit is contained in:
parent
942d747d89
commit
b0bcc46e22
3 changed files with 29 additions and 12 deletions
|
@ -2040,7 +2040,7 @@ fn parse_ilike() {
|
|||
pattern: Box::new(Expr::Value(
|
||||
(Value::SingleQuotedString("%a".to_string())).with_empty_span()
|
||||
)),
|
||||
escape_char: Some('^'.to_string()),
|
||||
escape_char: Some(Value::SingleQuotedString('^'.to_string())),
|
||||
any: false,
|
||||
},
|
||||
select.selection.unwrap()
|
||||
|
@ -2104,7 +2104,7 @@ fn parse_like() {
|
|||
pattern: Box::new(Expr::Value(
|
||||
(Value::SingleQuotedString("%a".to_string())).with_empty_span()
|
||||
)),
|
||||
escape_char: Some('^'.to_string()),
|
||||
escape_char: Some(Value::SingleQuotedString('^'.to_string())),
|
||||
any: false,
|
||||
},
|
||||
select.selection.unwrap()
|
||||
|
@ -2167,7 +2167,24 @@ fn parse_similar_to() {
|
|||
pattern: Box::new(Expr::Value(
|
||||
(Value::SingleQuotedString("%a".to_string())).with_empty_span()
|
||||
)),
|
||||
escape_char: Some('^'.to_string()),
|
||||
escape_char: Some(Value::SingleQuotedString('^'.to_string())),
|
||||
},
|
||||
select.selection.unwrap()
|
||||
);
|
||||
|
||||
let sql = &format!(
|
||||
"SELECT * FROM customers WHERE name {}SIMILAR TO '%a' ESCAPE NULL",
|
||||
if negated { "NOT " } else { "" }
|
||||
);
|
||||
let select = verified_only_select(sql);
|
||||
assert_eq!(
|
||||
Expr::SimilarTo {
|
||||
expr: Box::new(Expr::Identifier(Ident::new("name"))),
|
||||
negated,
|
||||
pattern: Box::new(Expr::Value(
|
||||
(Value::SingleQuotedString("%a".to_string())).with_empty_span()
|
||||
)),
|
||||
escape_char: Some(Value::Null),
|
||||
},
|
||||
select.selection.unwrap()
|
||||
);
|
||||
|
@ -2185,7 +2202,7 @@ fn parse_similar_to() {
|
|||
pattern: Box::new(Expr::Value(
|
||||
(Value::SingleQuotedString("%a".to_string())).with_empty_span()
|
||||
)),
|
||||
escape_char: Some('^'.to_string()),
|
||||
escape_char: Some(Value::SingleQuotedString('^'.to_string())),
|
||||
})),
|
||||
select.selection.unwrap()
|
||||
);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue