]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
Fixed bug in :func:`.postgresql.array` construct whereby using it
authorMike Bayer <mike_mp@zzzcomputing.com>
Wed, 2 Jan 2013 16:26:37 +0000 (11:26 -0500)
committerMike Bayer <mike_mp@zzzcomputing.com>
Wed, 2 Jan 2013 16:26:37 +0000 (11:26 -0500)
inside of an :func:`.expression.insert` construct would produce an
error regarding a parameter issue in the ``self_group()`` method.

doc/build/changelog/changelog_08.rst
lib/sqlalchemy/dialects/postgresql/base.py
test/dialect/test_postgresql.py

index 6c584e4b4f2b0e4989e7feb597debed283079c40..a71f95d5353550f1a751b08fc38bb7144d7f3dbb 100644 (file)
@@ -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
 
index 8866b69961f6a7e844c1c3b906f0fae890bc5169..81d2079c0569e188555e15168a42b96a3f1d3feb 100644 (file)
@@ -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
 
 
index 38a1d51a3384da516bfb7b574e09f71fe3e27f3f..4a506d5446033f2eba77dabdd323b84eaf117fcd 100644 (file)
@@ -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)))