From: Mike Bayer Date: Wed, 3 Jan 2007 02:19:57 +0000 (+0000) Subject: - order of constraint creation puts primary key first before all other constraints; X-Git-Tag: rel_0_3_4~61 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b6fc094c2c922f85555c2526b034ece5d0f32eef;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git - order of constraint creation puts primary key first before all other constraints; required for firebird, not a bad idea for others [ticket:408] --- diff --git a/CHANGES b/CHANGES index d584564be2..76bbad7407 100644 --- 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"]) diff --git a/lib/sqlalchemy/ansisql.py b/lib/sqlalchemy/ansisql.py index 225188eb3f..46131def2d 100644 --- a/lib/sqlalchemy/ansisql.py +++ b/lib/sqlalchemy/ansisql.py @@ -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))