summaryrefslogtreecommitdiff
path: root/test/dialect/postgresql/test_compiler.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2014-05-16 13:09:50 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2014-05-16 13:09:50 -0400
commit460465a8749aecff761e1c81c77d7c23e8672789 (patch)
tree958437d4e37a6a7cb28a5c53d6dd33f6ea4d5f23 /test/dialect/postgresql/test_compiler.py
parentacb13668c2988179dbee68f599492a533e817d0e (diff)
downloadsqlalchemy-460465a8749aecff761e1c81c77d7c23e8672789.tar.gz
- changelog for #2785
- refactor tests a bit fixes #2785
Diffstat (limited to 'test/dialect/postgresql/test_compiler.py')
-rw-r--r--test/dialect/postgresql/test_compiler.py44
1 files changed, 15 insertions, 29 deletions
diff --git a/test/dialect/postgresql/test_compiler.py b/test/dialect/postgresql/test_compiler.py
index 35f7b1199..c81389385 100644
--- a/test/dialect/postgresql/test_compiler.py
+++ b/test/dialect/postgresql/test_compiler.py
@@ -428,58 +428,44 @@ class CompileTest(fixtures.TestBase, AssertsCompiledSQL):
checkparams={'param_1': 7}
)
- def test_array_shift_indexes(self):
- c = Column('x', postgresql.ARRAY(Integer, zero_indexes=True))
+ def _test_array_zero_indexes(self, zero_indexes):
+ c = Column('x', postgresql.ARRAY(Integer, zero_indexes=zero_indexes))
+
+ add_one = 1 if zero_indexes else 0
self.assert_compile(
- cast(c, postgresql.ARRAY(Integer, zero_indexes=True)),
+ cast(c, postgresql.ARRAY(Integer, zero_indexes=zero_indexes)),
"CAST(x AS INTEGER[])"
)
self.assert_compile(
c[5],
"x[%(x_1)s]",
- checkparams={'x_1': 6}
+ checkparams={'x_1': 5 + add_one}
)
self.assert_compile(
c[5:7],
"x[%(x_1)s:%(x_2)s]",
- checkparams={'x_2': 8, 'x_1': 6}
+ checkparams={'x_2': 7 + add_one, 'x_1': 5 + add_one}
)
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}
+ checkparams={'x_2': 7 + add_one, 'x_1': 5 + add_one,
+ 'param_1': 2 + add_one, 'param_2': 3 + add_one}
)
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}
+ checkparams={'x_2': 7 + add_one, 'x_1': 5 + add_one,
+ 'param_1': 3 + add_one}
)
- c = Column('x', postgresql.ARRAY(Integer, zero_indexes=False))
-
- self.assert_compile(
- c[5],
- "x[%(x_1)s]",
- checkparams={'x_1': 5}
- )
+ def test_array_zero_indexes_true(self):
+ self._test_array_zero_indexes(True)
- 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_zero_indexes_false(self):
+ self._test_array_zero_indexes(False)
def test_array_literal_type(self):
is_(postgresql.array([1, 2]).type._type_affinity, postgresql.ARRAY)