]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- result.last_inserted_ids() should return a list that is identically
authorMike Bayer <mike_mp@zzzcomputing.com>
Mon, 11 Jun 2007 22:39:03 +0000 (22:39 +0000)
committerMike Bayer <mike_mp@zzzcomputing.com>
Mon, 11 Jun 2007 22:39:03 +0000 (22:39 +0000)
    sized to the primary key constraint of the table.  values that were
    "passively" created and not available via cursor.lastrowid will be None.

CHANGES
lib/sqlalchemy/databases/mysql.py
lib/sqlalchemy/databases/sqlite.py
lib/sqlalchemy/engine/default.py

diff --git a/CHANGES b/CHANGES
index 1c2cc8d604cca7fd2d4fb7264f769d1f1d83e42c..dab2fd67aa15ccb2d791a6ec344ce36aef3d3d13 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -28,6 +28,9 @@
     - added undefer_group() MapperOption, sets a set of "deferred"
       columns joined by a "group" to load as "undeferred".
 - sql
+  - result.last_inserted_ids() should return a list that is identically
+    sized to the primary key constraint of the table.  values that were 
+    "passively" created and not available via cursor.lastrowid will be None.
   - long-identifier detection fixed to use > rather than >= for 
     max ident length [ticket:589]
   - fixed bug where selectable.corresponding_column(selectable.c.col)
index db03ce04a717c06a549e2a84831c25cbe2d83e3c..8b4b89d508d6557f4fbe7ca0b5347e7d81c7830a 100644 (file)
@@ -951,7 +951,7 @@ def descriptor():
 class MySQLExecutionContext(default.DefaultExecutionContext):
     def post_exec(self):
         if self.compiled.isinsert:
-            self._last_inserted_ids = [self.cursor.lastrowid]
+            self._last_inserted_ids = [self.cursor.lastrowid] + self._last_inserted_ids[1:]
 
 class MySQLDialect(ansisql.ANSIDialect):
     def __init__(self, **kwargs):
index 1876305235620cb69061e238999a2d193bf78713..425009f6dc70249e37c38481b12e9b28d27c68a3 100644 (file)
@@ -139,7 +139,7 @@ def descriptor():
 class SQLiteExecutionContext(default.DefaultExecutionContext):
     def post_exec(self):
         if self.compiled.isinsert:
-            self._last_inserted_ids = [self.cursor.lastrowid]
+            self._last_inserted_ids = [self.cursor.lastrowid] + self._last_inserted_ids[1:]
         super(SQLiteExecutionContext, self).post_exec()
         
 class SQLiteDialect(ansisql.ANSIDialect):
index 976da1a73b869f78a4bb70d3a5b6040de0f9ad7b..19dd623bfe51d627d8645c6fe9023243dc3d74e6 100644 (file)
@@ -291,7 +291,7 @@ class DefaultExecutionContext(base.ExecutionContext):
                     if c in self.compiled.inline_params:
                         self._lastrow_has_defaults = True
                         if c.primary_key:
-                            need_lastrowid = True
+                            last_inserted_ids.append(None)
                     # check if its not present at all.  see if theres a default
                     # and fire it off, and add to bind parameters.  if
                     # its a pk, add the value to our last_inserted_ids list,
@@ -306,15 +306,12 @@ class DefaultExecutionContext(base.ExecutionContext):
                             if c.primary_key:
                                 last_inserted_ids.append(param.get_processed(c.key))
                         elif c.primary_key:
-                            need_lastrowid = True
+                            last_inserted_ids.append(None)
                     # its an explicitly passed pk value - add it to
                     # our last_inserted_ids list.
                     elif c.primary_key:
                         last_inserted_ids.append(param.get_processed(c.key))
-                if need_lastrowid:
-                    self._last_inserted_ids = None
-                else:
-                    self._last_inserted_ids = last_inserted_ids
+                self._last_inserted_ids = last_inserted_ids
                 self._last_inserted_params = param
         elif self.compiled.isupdate:
             if isinstance(self.compiled_parameters, list):