summaryrefslogtreecommitdiff
path: root/test/dialect/postgresql/test_compiler.py
diff options
context:
space:
mode:
authorAlexey Terentev <alexey@terentyev.su>2014-05-13 13:10:39 +0400
committerAlexey Terentev <alexey@terentyev.su>2014-05-13 15:48:29 +0400
commit57b6da9d402f164605c7bfe270654725cb604f1f (patch)
treee913d44cb0838bc8bdb84092ddec50f73c2573bd /test/dialect/postgresql/test_compiler.py
parent1abd53a3556b9593d9eba868d69c13bae3c3a7ab (diff)
downloadsqlalchemy-57b6da9d402f164605c7bfe270654725cb604f1f.tar.gz
zero_indexes-param-for-postgresql-ARRAY-type
Diffstat (limited to 'test/dialect/postgresql/test_compiler.py')
-rw-r--r--test/dialect/postgresql/test_compiler.py53
1 files changed, 53 insertions, 0 deletions
diff --git a/test/dialect/postgresql/test_compiler.py b/test/dialect/postgresql/test_compiler.py
index db6efa34a..35f7b1199 100644
--- a/test/dialect/postgresql/test_compiler.py
+++ b/test/dialect/postgresql/test_compiler.py
@@ -428,6 +428,59 @@ class CompileTest(fixtures.TestBase, AssertsCompiledSQL):
checkparams={'param_1': 7}
)
+ def test_array_shift_indexes(self):
+ c = Column('x', postgresql.ARRAY(Integer, zero_indexes=True))
+
+ self.assert_compile(
+ cast(c, postgresql.ARRAY(Integer, zero_indexes=True)),
+ "CAST(x AS INTEGER[])"
+ )
+ self.assert_compile(
+ c[5],
+ "x[%(x_1)s]",
+ checkparams={'x_1': 6}
+ )
+
+ self.assert_compile(
+ c[5:7],
+ "x[%(x_1)s:%(x_2)s]",
+ checkparams={'x_2': 8, 'x_1': 6}
+ )
+ self.assert_compile(
+ c[5:7][2:3],
+ "x[%(x_1)s:%(x_2)s][%(param_1)s:%(param_2)s]",
+ checkparams={'x_2': 8, 'x_1': 6, 'param_1': 3, 'param_2': 4}
+ )
+ self.assert_compile(
+ c[5:7][3],
+ "x[%(x_1)s:%(x_2)s][%(param_1)s]",
+ checkparams={'x_2': 8, 'x_1': 6, 'param_1': 4}
+ )
+
+ c = Column('x', postgresql.ARRAY(Integer, zero_indexes=False))
+
+ self.assert_compile(
+ c[5],
+ "x[%(x_1)s]",
+ checkparams={'x_1': 5}
+ )
+
+ self.assert_compile(
+ c[5:7],
+ "x[%(x_1)s:%(x_2)s]",
+ checkparams={'x_2': 7, 'x_1': 5}
+ )
+ self.assert_compile(
+ c[5:7][2:3],
+ "x[%(x_1)s:%(x_2)s][%(param_1)s:%(param_2)s]",
+ checkparams={'x_2': 7, 'x_1': 5, 'param_1': 2, 'param_2': 3}
+ )
+ self.assert_compile(
+ c[5:7][3],
+ "x[%(x_1)s:%(x_2)s][%(param_1)s]",
+ checkparams={'x_2': 7, 'x_1': 5, 'param_1': 3}
+ )
+
def test_array_literal_type(self):
is_(postgresql.array([1, 2]).type._type_affinity, postgresql.ARRAY)
is_(postgresql.array([1, 2]).type.item_type._type_affinity, Integer)