diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2022-05-18 16:06:29 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2022-05-22 15:25:58 -0400 |
commit | 719197dd9399b4436aeaba3e2f44761292036ad6 (patch) | |
tree | e96ab9de424d9faa5add9105260fd5471cdf6fa6 /test/sql/test_operators.py | |
parent | 0620614f95f62f35396e63c636cae98a0759f3ab (diff) | |
download | sqlalchemy-719197dd9399b4436aeaba3e2f44761292036ad6.tar.gz |
use plainto_tsquery for PG match
The :meth:`.Operators.match` operator now uses ``plainto_tsquery()`` for
PostgreSQL full text search, rather than ``to_tsquery()``. The rationale
for this change is to provide better cross-compatibility with match on
other database backends. Full support for all PostgreSQL full text
functions remains available through the use of :data:`.func` in
conjunction with :meth:`.Operators.bool_op` (an improved version of
:meth:`.Operators.op` for boolean operators).
Additional doc updates here apply to 1.4 so will backport these
out to a separate commit.
Fixes: #7086
Change-Id: I1946075daf5d9c558e85f73f1bf852604b3b1b8c
Diffstat (limited to 'test/sql/test_operators.py')
-rw-r--r-- | test/sql/test_operators.py | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/test/sql/test_operators.py b/test/sql/test_operators.py index 6f068159e..2411fb0a3 100644 --- a/test/sql/test_operators.py +++ b/test/sql/test_operators.py @@ -2862,7 +2862,7 @@ class MatchTest(fixtures.TestBase, testing.AssertsCompiledSQL): def test_match_4(self): self.assert_compile( self.table1.c.myid.match("somstr"), - "mytable.myid @@ to_tsquery(%(myid_1)s)", + "mytable.myid @@ plainto_tsquery(%(myid_1)s)", dialect=postgresql.dialect(), ) @@ -2881,7 +2881,7 @@ class MatchTest(fixtures.TestBase, testing.AssertsCompiledSQL): def test_boolean_inversion_postgresql(self): self.assert_compile( ~self.table1.c.myid.match("somstr"), - "NOT mytable.myid @@ to_tsquery(%(myid_1)s)", + "NOT mytable.myid @@ plainto_tsquery(%(myid_1)s)", dialect=postgresql.dialect(), ) @@ -3429,7 +3429,7 @@ class ComposedLikeOperatorsTest(fixtures.TestBase, testing.AssertsCompiledSQL): class CustomOpTest(fixtures.TestBase): - def test_is_comparison(self): + def test_is_comparison_legacy(self): c = column("x") c2 = column("y") op1 = c.op("$", is_comparison=True)(c2).operator @@ -3438,6 +3438,15 @@ class CustomOpTest(fixtures.TestBase): assert operators.is_comparison(op1) assert not operators.is_comparison(op2) + def test_is_comparison_bool_op(self): + c = column("x") + c2 = column("y") + op1 = c.bool_op("$")(c2).operator + op2 = c.op("$")(c2).operator + + assert operators.is_comparison(op1) + assert not operators.is_comparison(op2) + @testing.combinations( (sqltypes.NULLTYPE,), (Integer(),), |