Skip to content

Commit

Permalink
fix(cubestore): Escape regex symbols in all versions of like operator (
Browse files Browse the repository at this point in the history
  • Loading branch information
waralexrom committed Sep 28, 2023
1 parent 5e68c7c commit e58af39
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
6 changes: 3 additions & 3 deletions rust/cubestore/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions rust/cubestore/cubestore-sql-tests/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1621,6 +1621,17 @@ async fn ilike(service: Box<dyn SqlClient>) {
.unwrap();
assert_eq!(to_rows(&r), rows(&["some_underscore"]));

let r = service
.exec_query("SELECT t FROM s.strings WHERE t ILIKE CONCAT('%', '(', '%') ORDER BY t")
.await
.unwrap();
assert_eq!(to_rows(&r), rows(&["test ( special 2"]));

let r = service
.exec_query("SELECT t FROM s.strings WHERE t ILIKE CONCAT('%', '?*|+', '%') ORDER BY t")
.await
.unwrap();
assert_eq!(to_rows(&r), rows(&["111 test {)?*|+aaa"]));
// Compare constant string with a bunch of patterns.
// Inputs are: ('aba', '%ABA'), ('ABa', '%aba%'), ('CABA', 'aba%'), ('ZABA', '%a%b%a%'),
// ('ZZZ', 'zzz'), ('TTT', 'TTT').
Expand All @@ -1630,6 +1641,12 @@ async fn ilike(service: Box<dyn SqlClient>) {
.unwrap();
assert_eq!(to_rows(&r), rows(&["%ABA", "%a%b%a%", "%aba%", "aba%"]));

let r = service
.exec_query("SELECT pat FROM s.strings WHERE 'ggggtest (fjfj)' ILIKE pat ORDER BY pat")
.await
.unwrap();
assert_eq!(to_rows(&r), rows(&["%test (%"]));

// Compare array against array.
let r = service
.exec_query("SELECT t, pat FROM s.strings WHERE t ILIKE pat ORDER BY t")
Expand Down

0 comments on commit e58af39

Please sign in to comment.