diff options
author | Jason Kirtland <jek@discorporate.us> | 2007-10-23 01:47:21 +0000 |
---|---|---|
committer | Jason Kirtland <jek@discorporate.us> | 2007-10-23 01:47:21 +0000 |
commit | d89b2acdd7218ca179844c05be9d8f888d0c7ee6 (patch) | |
tree | 348cf9bda3cef0f75181f103aafe650fc2566b4b /lib/sqlalchemy/sql/compiler.py | |
parent | 8dfff3888f4ab28487a573cc5617c818c3975c2d (diff) | |
download | sqlalchemy-d89b2acdd7218ca179844c05be9d8f888d0c7ee6.tar.gz |
Added support for dialects that have both sequences and autoincrementing PKs.
Diffstat (limited to 'lib/sqlalchemy/sql/compiler.py')
-rw-r--r-- | lib/sqlalchemy/sql/compiler.py | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/sqlalchemy/sql/compiler.py b/lib/sqlalchemy/sql/compiler.py index 5572c2ed4..f2627eb85 100644 --- a/lib/sqlalchemy/sql/compiler.py +++ b/lib/sqlalchemy/sql/compiler.py @@ -674,9 +674,15 @@ 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_sequences and not self.inline: - values.append((c, create_bind_param(c, None))) - self.prefetch.add(c) + 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 + (c.default is not None and + not isinstance(c.default, schema.Sequence))): + values.append((c, create_bind_param(c, None))) + self.prefetch.add(c) elif isinstance(c.default, schema.ColumnDefault): if isinstance(c.default.arg, sql.ClauseElement): values.append((c, self.process(c.default.arg.self_group()))) |