summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2013-01-02 11:26:37 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2013-01-02 11:26:37 -0500
commita94f2f81afc859ea4553037cc12734311c8328b0 (patch)
tree20f43cedbe6968e86d296910f879df6b5cc8ccc5
parent14528afd6f080cf18028f7f71992ef5c14437907 (diff)
downloadsqlalchemy-a94f2f81afc859ea4553037cc12734311c8328b0.tar.gz
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.
-rw-r--r--doc/build/changelog/changelog_08.rst7
-rw-r--r--lib/sqlalchemy/dialects/postgresql/base.py2
-rw-r--r--test/dialect/test_postgresql.py9
3 files changed, 17 insertions, 1 deletions
diff --git a/doc/build/changelog/changelog_08.rst b/doc/build/changelog/changelog_08.rst
index 6c584e4b4..a71f95d53 100644
--- a/doc/build/changelog/changelog_08.rst
+++ b/doc/build/changelog/changelog_08.rst
@@ -7,6 +7,13 @@
: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
Extended the :doc:`/core/inspection` system so that all Python descriptors
diff --git a/lib/sqlalchemy/dialects/postgresql/base.py b/lib/sqlalchemy/dialects/postgresql/base.py
index 8866b6996..81d2079c0 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 38a1d51a3..4a506d544 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)))