From: Ants Aasma Date: Thu, 12 Jul 2007 01:00:46 +0000 (+0000) Subject: Fixed postgres array concatenation X-Git-Tag: rel_0_4_6~117 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2bb9552b5abedf5d49f5ae2b89ed85991bf3f25e;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git Fixed postgres array concatenation --- diff --git a/lib/sqlalchemy/databases/postgres.py b/lib/sqlalchemy/databases/postgres.py index 717eacd942..20088045e9 100644 --- a/lib/sqlalchemy/databases/postgres.py +++ b/lib/sqlalchemy/databases/postgres.py @@ -538,7 +538,7 @@ class PGCompiler(ansisql.ANSICompiler): return super(PGCompiler, self).for_update_clause(select) def binary_operator_string(self, binary): - if isinstance(binary.type, sqltypes.String) and binary.operator == '+': + if isinstance(binary.type, (sqltypes.String, PGArray)) and binary.operator == '+': return '||' elif binary.operator == '%': return '%%' diff --git a/test/dialect/postgres.py b/test/dialect/postgres.py index c9376d97d4..f5bd4a55fa 100644 --- a/test/dialect/postgres.py +++ b/test/dialect/postgres.py @@ -277,6 +277,14 @@ class ArrayTest(AssertMixin): self.assertEquals(len(results), 1) self.assertEquals(results[0]['intarr'], [1,2,3]) arrtable.delete().execute() + + @testbase.supported('postgres') + def test_array_concat(self): + arrtable.insert().execute(intarr=[1,2,3], strarr=['abc', 'def']) + results = select([arrtable.c.intarr + [4,5,6]]).execute().fetchall() + self.assertEquals(len(results), 1) + self.assertEquals(results[0][0], [1,2,3,4,5,6]) + arrtable.delete().execute() if __name__ == "__main__": testbase.main()