]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
don't create a bind for pk col + sequence if the backend doesn't support sequences
authorMike Bayer <mike_mp@zzzcomputing.com>
Wed, 29 Jul 2009 04:03:51 +0000 (04:03 +0000)
committerMike Bayer <mike_mp@zzzcomputing.com>
Wed, 29 Jul 2009 04:03:51 +0000 (04:03 +0000)
lib/sqlalchemy/sql/compiler.py

index 22fe956cb8b23cb8a201a659f78fbaac638847c1..810057946dd67fb62ef5f07c6e7b852ff25247fe 100644 (file)
@@ -792,6 +792,10 @@ class SQLCompiler(engine.Compiled):
 
             elif isinstance(c, schema.Column):
                 if self.isinsert:
+                    # TODO: need to mix this around some more until
+                    # conditionals are reduced.  might want to 
+                    # do primary key, then sequence/column default/none, 
+                    # then implicit_returning/supports sequence/doesnt
                     if c.primary_key and \
                         (
                             self.dialect.preexecute_pk_sequences or 
@@ -816,7 +820,13 @@ class SQLCompiler(engine.Compiled):
                             else:
                                 self.returning.append(c)
                         else:
-                            if c.default is not None or \
+                            if (
+                                c.default is not None and \
+                                    (
+                                        self.dialect.supports_sequences or 
+                                        not isinstance(c.default, schema.Sequence)
+                                    )
+                                ) or \
                                 self.dialect.preexecute_autoincrement_sequences:
 
                                 values.append((c, create_bind_param(c, None)))