diff options
| author | Federico Caselli <cfederico87@gmail.com> | 2020-11-15 16:58:46 +0100 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2020-11-19 13:49:32 -0500 |
| commit | ec264a5a2c810394ee4ebd7a78f83fc0ea785c1f (patch) | |
| tree | 8b4caff6a39429167584bcb4f9f5c39c1fbecc41 /lib/sqlalchemy/testing | |
| parent | cef2871ef99af3cc6a40d98a2651c6dad7542d75 (diff) | |
| download | sqlalchemy-ec264a5a2c810394ee4ebd7a78f83fc0ea785c1f.tar.gz | |
Use ``re.search`` instead of ``re.match`` in sqlite
Use python ``re.search()`` instead of ``re.match()`` as the operation
used by the :meth:`Column.regexp_match` method when using sqlite.
This matches the behavior of regular expressions on other databases
as well as that of well-known SQLite plugins.
Fixes: #5699
Change-Id: I14b2c7faf51fef172842aeb2dba2500f14544f24
Diffstat (limited to 'lib/sqlalchemy/testing')
| -rw-r--r-- | lib/sqlalchemy/testing/suite/test_select.py | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/lib/sqlalchemy/testing/suite/test_select.py b/lib/sqlalchemy/testing/suite/test_select.py index e7b733261..f8d9b3d88 100644 --- a/lib/sqlalchemy/testing/suite/test_select.py +++ b/lib/sqlalchemy/testing/suite/test_select.py @@ -1126,11 +1126,6 @@ class LikeFunctionsTest(fixtures.TablesTest): 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}) @@ -1142,6 +1137,20 @@ class LikeFunctionsTest(fixtures.TablesTest): col.regexp_replace("a.cde", "FOO").contains("FOO"), {1, 5, 6, 9} ) + @testing.requires.regexp_match + @testing.combinations( + ("a.cde", {1, 5, 6, 9}), + ("abc", {1, 5, 6, 9, 10}), + ("^abc", {1, 5, 6, 9, 10}), + ("9cde", {8}), + ("^a", set(range(1, 11))), + ("(b|c)", set(range(1, 11))), + ("^(b|c)", set()), + ) + def test_regexp_match(self, text, expected): + col = self.tables.some_table.c.data + self._test(col.regexp_match(text), expected) + class ComputedColumnTest(fixtures.TablesTest): __backend__ = True |
