Merge "Accomodate for multidimensional array in rewriting for COLLATE"

This commit is contained in:
mike bayer
2017-09-27 15:47:47 -04:00
committed by Gerrit Code Review
3 changed files with 35 additions and 2 deletions
+8
View File
@@ -0,0 +1,8 @@
.. change:: 4006
:tags: bug, postgresql
:tickets: 4006
:versions: 1.2.0b3
Made further fixes to the :class:`.ARRAY` class in conjunction with
COLLATE, as the fix made in :ticket:`4006` failed to accommodate
for a multidimentional array.
+4 -2
View File
@@ -1897,8 +1897,10 @@ class PGTypeCompiler(compiler.GenericTypeCompiler):
inner = self.process(type_.item_type)
return re.sub(
r'((?: COLLATE.*)?)$',
(r'[]\1' *
(type_.dimensions if type_.dimensions is not None else 1)),
(r'%s\1' % (
"[]" *
(type_.dimensions if type_.dimensions is not None else 1)
)),
inner
)
+23
View File
@@ -842,6 +842,29 @@ class ArrayTest(AssertsCompiledSQL, fixtures.TestBase):
'VARCHAR(30)[] COLLATE "en_US"'
)
def test_array_type_render_str_multidim(self):
self.assert_compile(
postgresql.ARRAY(Unicode(30), dimensions=2),
"VARCHAR(30)[][]"
)
self.assert_compile(
postgresql.ARRAY(Unicode(30), dimensions=3),
"VARCHAR(30)[][][]"
)
def test_array_type_render_str_collate_multidim(self):
self.assert_compile(
postgresql.ARRAY(Unicode(30, collation="en_US"), dimensions=2),
'VARCHAR(30)[][] COLLATE "en_US"'
)
self.assert_compile(
postgresql.ARRAY(Unicode(30, collation="en_US"), dimensions=3),
'VARCHAR(30)[][][] COLLATE "en_US"'
)
def test_array_int_index(self):
col = column('x', postgresql.ARRAY(Integer))
self.assert_compile(