summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/sql
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2007-10-28 21:28:53 +0000
committerMike Bayer <mike_mp@zzzcomputing.com>2007-10-28 21:28:53 +0000
commitbbebcdf8f526226d2d64a91dfc306086fc9873f4 (patch)
tree9d7ae997a5f816418ac05b20b22f523653fc32f6 /lib/sqlalchemy/sql
parent19fcf37483b381d795239fa328d08ce97b87ed90 (diff)
downloadsqlalchemy-bbebcdf8f526226d2d64a91dfc306086fc9873f4.tar.gz
- fixed INSERT statements w.r.t. primary key columns that have SQL-expression
based default generators on them; SQL expression executes inline as normal but will not trigger a "postfetch" condition for the column, for those DB's who provide it via cursor.lastrowid
Diffstat (limited to 'lib/sqlalchemy/sql')
-rw-r--r--lib/sqlalchemy/sql/compiler.py13
1 files changed, 8 insertions, 5 deletions
diff --git a/lib/sqlalchemy/sql/compiler.py b/lib/sqlalchemy/sql/compiler.py
index e662f8e99..43b6fb15b 100644
--- a/lib/sqlalchemy/sql/compiler.py
+++ b/lib/sqlalchemy/sql/compiler.py
@@ -664,8 +664,7 @@ class DefaultCompiler(engine.Compiled, visitors.ClauseVisitor):
values.append((c, value))
elif isinstance(c, schema.Column):
if self.isinsert:
- if (c.primary_key and self.dialect.preexecute_pk_sequences
- and not self.inline):
+ if (c.primary_key and self.dialect.preexecute_pk_sequences and not self.inline):
if (((isinstance(c.default, schema.Sequence) and
not c.default.optional) or
not self.dialect.supports_pk_autoincrement) or
@@ -676,17 +675,21 @@ class DefaultCompiler(engine.Compiled, visitors.ClauseVisitor):
elif isinstance(c.default, schema.ColumnDefault):
if isinstance(c.default.arg, sql.ClauseElement):
values.append((c, self.process(c.default.arg.self_group())))
- self.postfetch.add(c)
+ if not c.primary_key:
+ # dont add primary key column to postfetch
+ self.postfetch.add(c)
else:
values.append((c, create_bind_param(c, None)))
self.prefetch.add(c)
elif isinstance(c.default, schema.PassiveDefault):
- self.postfetch.add(c)
+ if not c.primary_key:
+ self.postfetch.add(c)
elif isinstance(c.default, schema.Sequence):
proc = self.process(c.default)
if proc is not None:
values.append((c, proc))
- self.postfetch.add(c)
+ if not c.primary_key:
+ self.postfetch.add(c)
elif self.isupdate:
if isinstance(c.onupdate, schema.ColumnDefault):
if isinstance(c.onupdate.arg, sql.ClauseElement):