summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/testing/suite
diff options
context:
space:
mode:
authorFederico Caselli <cfederico87@gmail.com>2020-07-16 21:32:52 +0200
committerMike Bayer <mike_mp@zzzcomputing.com>2020-08-27 17:30:18 -0400
commitb1b97ed1fcac777c4f42fdf84e05f8d59f63b679 (patch)
tree93b67e4ae3eff79d3e49bca71cddac40cf40b9bd /lib/sqlalchemy/testing/suite
parentfe772672b4fc00df0b66aca92e2092779a844a2d (diff)
downloadsqlalchemy-b1b97ed1fcac777c4f42fdf84e05f8d59f63b679.tar.gz
Add support for regular expression on supported backend.
Two operations have been defined: * :meth:`~.ColumnOperators.regexp_match` implementing a regular expression match like function. * :meth:`~.ColumnOperators.regexp_replace` implementing a regular expression string replace function. Fixes: #1390 Change-Id: I44556846e4668ccf329023613bd26861d5c674e6
Diffstat (limited to 'lib/sqlalchemy/testing/suite')
-rw-r--r--lib/sqlalchemy/testing/suite/test_select.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/sqlalchemy/testing/suite/test_select.py b/lib/sqlalchemy/testing/suite/test_select.py
index 675fac609..7e0337146 100644
--- a/lib/sqlalchemy/testing/suite/test_select.py
+++ b/lib/sqlalchemy/testing/suite/test_select.py
@@ -1004,6 +1004,23 @@ class LikeFunctionsTest(fixtures.TablesTest):
self._test(col.contains("b%cd", autoescape=True, escape="#"), {3})
self._test(col.contains("b#cd", autoescape=True, escape="#"), {7})
+ @testing.requires.regexp_match
+ def test_regexp_match(self):
+ col = self.tables.some_table.c.data
+ self._test(col.regexp_match("a.cde"), {1, 5, 6, 9})
+
+ @testing.requires.regexp_match
+ def test_not_regexp_match(self):
+ col = self.tables.some_table.c.data
+ self._test(~col.regexp_match("a.cde"), {2, 3, 4, 7, 8, 10})
+
+ @testing.requires.regexp_replace
+ def test_regexp_replace(self):
+ col = self.tables.some_table.c.data
+ self._test(
+ col.regexp_replace("a.cde", "FOO").contains("FOO"), {1, 5, 6, 9}
+ )
+
class ComputedColumnTest(fixtures.TablesTest):
__backend__ = True