summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2010-04-22 11:24:25 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2010-04-22 11:24:25 -0400
commitae495c69adacdd341d4ab22df4eedbbc6cb9df8e (patch)
tree5d6aadc70a7fa1aec4e12cd6f64cf0cbd482b18c
parent38d6c31a29b28577aabb5ae2e641cf95a3cdbc7a (diff)
downloadsqlalchemy-ae495c69adacdd341d4ab22df4eedbbc6cb9df8e.tar.gz
- Fixed bug that prevented implicit RETURNING from functioning
properly with composite primary key that contained zeroes. [ticket:1778]
-rw-r--r--CHANGES5
-rw-r--r--lib/sqlalchemy/engine/default.py11
-rw-r--r--test/sql/test_query.py9
3 files changed, 22 insertions, 3 deletions
diff --git a/CHANGES b/CHANGES
index 4f853b290..01283843f 100644
--- 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
diff --git a/lib/sqlalchemy/engine/default.py b/lib/sqlalchemy/engine/default.py
index fc49c62fa..a8c336336 100644
--- a/lib/sqlalchemy/engine/default.py
+++ b/lib/sqlalchemy/engine/default.py
@@ -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
diff --git a/test/sql/test_query.py b/test/sql/test_query.py
index 80d524bf1..5a4f03311 100644
--- a/test/sql/test_query.py
+++ b/test/sql/test_query.py
@@ -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