]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- Fixed bug that prevented implicit RETURNING from functioning
authorMike Bayer <mike_mp@zzzcomputing.com>
Thu, 22 Apr 2010 15:24:25 +0000 (11:24 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Thu, 22 Apr 2010 15:24:25 +0000 (11:24 -0400)
properly with composite primary key that contained zeroes.
[ticket:1778]

CHANGES
lib/sqlalchemy/engine/default.py
test/sql/test_query.py

diff --git a/CHANGES b/CHANGES
index 4f853b290067f1cceeaa637c30cf03e68caaeeda..01283843f41a47f04fd2771a1d63bde96fd1c25f 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -5,6 +5,11 @@ CHANGES
 =======
 0.6.1
 =====
+- sql
+  - Fixed bug that prevented implicit RETURNING from functioning
+    properly with composite primary key that contained zeroes.
+    [ticket:1778]
+    
 - oracle
   - Added a check for cx_oracle versions lower than version 5,
     in which case the incompatible "output type handler" won't 
index fc49c62fac7bb28def478bccbab383e2fe847976..a8c336336e3c8133f22b3fbe6cf5c0262891d28b 100644 (file)
@@ -576,9 +576,14 @@ class DefaultExecutionContext(base.ExecutionContext):
         table = self.compiled.statement.table
         row = resultproxy.fetchone()
 
-        self._inserted_primary_key = [v is not None and v or row[c] 
-            for c, v in zip(table.primary_key, self._inserted_primary_key)
-        ]
+        ipk = []
+        for c, v in zip(table.primary_key, self._inserted_primary_key):
+            if v is not None:
+                ipk.append(v)
+            else:
+                ipk.append(row[c])
+        
+        self._inserted_primary_key = ipk
 
     def last_inserted_params(self):
         return self._last_inserted_params
index 80d524bf12ceb7fb812b5a1c36a6908fe67f20e6..5a4f033112d2227b53454fd6ca29666800dfbef5 100644 (file)
@@ -160,6 +160,15 @@ class QueryTest(TestBase):
                     {'id':'id1'},
                     {'id':'id1', 'bar':'hi'},
                 ),
+                (
+                    {'unsupported':['sqlite']},
+                    Table("t6", metadata,
+                        Column('id', Integer, primary_key=True, test_needs_autoincrement=True),
+                        Column('bar', Integer, primary_key=True)
+                    ),
+                    {'bar':0},
+                    {'id':1, 'bar':0},
+                ),
             ]:
                 if testing.db.name in supported['unsupported']:
                     continue