]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- order of constraint creation puts primary key first before all other constraints;
authorMike Bayer <mike_mp@zzzcomputing.com>
Wed, 3 Jan 2007 02:19:57 +0000 (02:19 +0000)
committerMike Bayer <mike_mp@zzzcomputing.com>
Wed, 3 Jan 2007 02:19:57 +0000 (02:19 +0000)
required for firebird, not a bad idea for others [ticket:408]

CHANGES
lib/sqlalchemy/ansisql.py

diff --git a/CHANGES b/CHANGES
index d584564be2d954818e932390927b89809ca757a0..76bbad7407bf243dbff2f4f272850b5698572534 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -15,6 +15,8 @@ non-ambiguous.
 - invalid options sent to 'cascade' string will raise an exception [ticket:406]
 - fixed bug in mapper refresh/expire whereby eager loaders didnt properly re-populate
 item lists [ticket:407]
+- order of constraint creation puts primary key first before all other constraints;
+required for firebird, not a bad idea for others [ticket:408]
 
 0.3.3
 - string-based FROM clauses fixed, i.e. select(..., from_obj=["sometext"])
index 225188eb3ffb38501a3458a5c822ab544662ff80..46131def2d02eb552693022dadbeffe5a5751bf0 100644 (file)
@@ -701,8 +701,12 @@ class ANSISchemaGenerator(ANSISchemaBase):
                 first_pk = True
             for constraint in column.constraints:
                 constraint.accept_schema_visitor(self, traverse=False)
-                
-        for constraint in table.constraints:
+
+        # On some DB order is significant: visit PK first, then the
+        # other constraints (engine.ReflectionTest.testbasic failed on FB2)
+        if len(table.primary_key):
+            table.primary_key.accept_schema_visitor(self, traverse=False)
+        for constraint in [c for c in table.constraints if c is not table.primary_key]:
             constraint.accept_schema_visitor(self, traverse=False)
 
         self.append("\n)%s\n\n" % self.post_create_table(table))