diff options
author | Audrius Kažukauskas <audrius@neutrino.lt> | 2013-01-28 19:58:06 +0200 |
---|---|---|
committer | Audrius Kažukauskas <audrius@neutrino.lt> | 2013-01-28 19:58:06 +0200 |
commit | dbdf4f25e2b1054e8f843f8ed0256ece86d68080 (patch) | |
tree | 3b7be63ca7cee6acc9e62b1f4d757cb93aca89ee /test/dialect/test_postgresql.py | |
parent | 684d8d4c8112b34bbe5d5e35bb2ecba1686fda4c (diff) | |
download | sqlalchemy-dbdf4f25e2b1054e8f843f8ed0256ece86d68080.tar.gz |
Add ANY/ALL construct support for PostgreSQL's ARRAY type
Diffstat (limited to 'test/dialect/test_postgresql.py')
-rw-r--r-- | test/dialect/test_postgresql.py | 50 |
1 files changed, 49 insertions, 1 deletions
diff --git a/test/dialect/test_postgresql.py b/test/dialect/test_postgresql.py index ff958e7b8..3337fa6ab 100644 --- a/test/dialect/test_postgresql.py +++ b/test/dialect/test_postgresql.py @@ -20,7 +20,7 @@ from sqlalchemy.dialects.postgresql import base as postgresql from sqlalchemy.dialects.postgresql import HSTORE, hstore, array, ARRAY from sqlalchemy.util.compat import decimal from sqlalchemy.testing.util import round_decimal -from sqlalchemy.sql import table, column +from sqlalchemy.sql import table, column, operators import logging import re @@ -290,6 +290,26 @@ class CompileTest(fixtures.TestBase, AssertsCompiledSQL): 'x && %(x_1)s', checkparams={'x_1': [3]} ) + self.assert_compile( + postgresql.Any(4, c), + '%(param_1)s = ANY (x)', + checkparams={'param_1': 4} + ) + self.assert_compile( + c.any(5, operator=operators.ne), + '%(param_1)s != ANY (x)', + checkparams={'param_1': 5} + ) + self.assert_compile( + postgresql.All(6, c, operator=operators.gt), + '%(param_1)s > ALL (x)', + checkparams={'param_1': 6} + ) + self.assert_compile( + c.all(7, operator=operators.lt), + '%(param_1)s < ALL (x)', + checkparams={'param_1': 7} + ) def test_array_literal_type(self): is_(postgresql.array([1, 2]).type._type_affinity, postgresql.ARRAY) @@ -2274,6 +2294,34 @@ class ArrayTest(fixtures.TestBase, AssertsExecutionResults): [4, 5, 6] ) + def test_array_any_exec(self): + with testing.db.connect() as conn: + conn.execute( + arrtable.insert(), + intarr=[4, 5, 6] + ) + eq_( + conn.scalar( + select([arrtable.c.intarr]). + where(postgresql.Any(5, arrtable.c.intarr)) + ), + [4, 5, 6] + ) + + def test_array_all_exec(self): + with testing.db.connect() as conn: + conn.execute( + arrtable.insert(), + intarr=[4, 5, 6] + ) + eq_( + conn.scalar( + select([arrtable.c.intarr]). + where(arrtable.c.intarr.all(4, operator=operators.le)) + ), + [4, 5, 6] + ) + @testing.provide_metadata def test_tuple_flag(self): metadata = self.metadata |