From 2bb9552b5abedf5d49f5ae2b89ed85991bf3f25e Mon Sep 17 00:00:00 2001 From: Ants Aasma Date: Thu, 12 Jul 2007 01:00:46 +0000 Subject: [PATCH] Fixed postgres array concatenation --- lib/sqlalchemy/databases/postgres.py | 2 +- test/dialect/postgres.py | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) 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() -- 2.47.3