summaryrefslogtreecommitdiff
path: root/test/dialect/postgresql
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2014-07-25 16:08:21 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2014-07-25 16:08:21 -0400
commitd92177cede956e4ca12e0fdad5021bdd54715161 (patch)
tree6b5c5514dd576007c23052d73370ecd833914a0c /test/dialect/postgresql
parentb7e75172b391f728451c59c4f9eba2b79143bf66 (diff)
downloadsqlalchemy-d92177cede956e4ca12e0fdad5021bdd54715161.tar.gz
- Fixed bug in :class:`.postgresql.array` object where comparison
to a plain Python list would fail to use the correct array constructor. Pull request courtesy Andrew. fixes #3141
Diffstat (limited to 'test/dialect/postgresql')
-rw-r--r--test/dialect/postgresql/test_compiler.py10
-rw-r--r--test/dialect/postgresql/test_types.py19
2 files changed, 29 insertions, 0 deletions
diff --git a/test/dialect/postgresql/test_compiler.py b/test/dialect/postgresql/test_compiler.py
index c71852d90..b08fb0160 100644
--- a/test/dialect/postgresql/test_compiler.py
+++ b/test/dialect/postgresql/test_compiler.py
@@ -501,6 +501,16 @@ class CompileTest(fixtures.TestBase, AssertsCompiledSQL):
'param_3': 3, 'param_2': 2}
)
+ def test_array_literal_compare(self):
+ self.assert_compile(
+ postgresql.array([1, 2]) == [3, 4, 5],
+ "ARRAY[%(param_1)s, %(param_2)s] = "
+ "ARRAY[%(param_3)s, %(param_4)s, %(param_5)s]",
+ checkparams={'param_5': 5, 'param_4': 4, 'param_1': 1,
+ 'param_3': 3, 'param_2': 2}
+
+ )
+
def test_array_literal_insert(self):
m = MetaData()
t = Table('t', m, Column('data', postgresql.ARRAY(Integer)))
diff --git a/test/dialect/postgresql/test_types.py b/test/dialect/postgresql/test_types.py
index 33219ce4c..457ddce0d 100644
--- a/test/dialect/postgresql/test_types.py
+++ b/test/dialect/postgresql/test_types.py
@@ -644,6 +644,16 @@ class ArrayTest(fixtures.TablesTest, AssertsExecutionResults):
eq_(len(results), 1)
eq_(results[0][0], [1, 2, 3, 4, 5, 6, ])
+ def test_array_comparison(self):
+ arrtable = self.tables.arrtable
+ arrtable.insert().execute(intarr=[1, 2, 3],
+ strarr=[util.u('abc'), util.u('def')])
+ results = select([arrtable.c.id]).\
+ where(arrtable.c.intarr < [4, 5, 6]).execute()\
+ .fetchall()
+ eq_(len(results), 1)
+ eq_(results[0][0], 3)
+
def test_array_subtype_resultprocessor(self):
arrtable = self.tables.arrtable
arrtable.insert().execute(intarr=[4, 5, 6],
@@ -668,6 +678,15 @@ class ArrayTest(fixtures.TablesTest, AssertsExecutionResults):
), [1, 2, 3, 4, 5]
)
+ def test_array_literal_compare(self):
+ eq_(
+ testing.db.scalar(
+ select([
+ postgresql.array([1, 2]) < [3, 4, 5]
+ ])
+ ), True
+ )
+
def test_array_getitem_single_type(self):
arrtable = self.tables.arrtable
is_(arrtable.c.intarr[1].type._type_affinity, Integer)