From b6fc094c2c922f85555c2526b034ece5d0f32eef Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Wed, 3 Jan 2007 02:19:57 +0000 Subject: [PATCH] - order of constraint creation puts primary key first before all other constraints; required for firebird, not a bad idea for others [ticket:408] --- CHANGES | 2 ++ lib/sqlalchemy/ansisql.py | 8 ++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) 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)) -- 2.47.2