From: Mike Bayer Date: Wed, 2 Jan 2013 16:26:37 +0000 (-0500) Subject: Fixed bug in :func:`.postgresql.array` construct whereby using it X-Git-Tag: rel_0_8_0~35^2~5 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a94f2f81afc859ea4553037cc12734311c8328b0;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git Fixed bug in :func:`.postgresql.array` construct whereby using it inside of an :func:`.expression.insert` construct would produce an error regarding a parameter issue in the ``self_group()`` method. --- diff --git a/doc/build/changelog/changelog_08.rst b/doc/build/changelog/changelog_08.rst index 6c584e4b4f..a71f95d535 100644 --- a/doc/build/changelog/changelog_08.rst +++ b/doc/build/changelog/changelog_08.rst @@ -6,6 +6,13 @@ .. changelog:: :version: 0.8.0 + .. change:: + :tags: postgresql, bug + + Fixed bug in :func:`.postgresql.array` construct whereby using it + inside of an :func:`.expression.insert` construct would produce an + error regarding a parameter issue in the ``self_group()`` method. + .. change:: :tags: orm, feature diff --git a/lib/sqlalchemy/dialects/postgresql/base.py b/lib/sqlalchemy/dialects/postgresql/base.py index 8866b69961..81d2079c05 100644 --- a/lib/sqlalchemy/dialects/postgresql/base.py +++ b/lib/sqlalchemy/dialects/postgresql/base.py @@ -411,7 +411,7 @@ class array(expression.Tuple): for o in obj ]) - def self_group(self, against): + def self_group(self, against=None): return self diff --git a/test/dialect/test_postgresql.py b/test/dialect/test_postgresql.py index 38a1d51a33..4a506d5446 100644 --- a/test/dialect/test_postgresql.py +++ b/test/dialect/test_postgresql.py @@ -319,6 +319,15 @@ class CompileTest(fixtures.TestBase, AssertsCompiledSQL): 'param_3': 3, 'param_2': 2} ) + def test_array_literal_insert(self): + m = MetaData() + t = Table('t', m, Column('data', postgresql.ARRAY(Integer))) + self.assert_compile( + t.insert().values(data=array([1, 2, 3])), + "INSERT INTO t (data) VALUES (ARRAY[%(param_1)s, " + "%(param_2)s, %(param_3)s])" + ) + def test_update_array_element(self): m = MetaData() t = Table('t', m, Column('data', postgresql.ARRAY(Integer)))