]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
Corrected problems with reflection on mssql when dealing with schemas. Fixes #1217.
authorMichael Trier <mtrier@gmail.com>
Sun, 9 Nov 2008 01:27:25 +0000 (01:27 +0000)
committerMichael Trier <mtrier@gmail.com>
Sun, 9 Nov 2008 01:27:25 +0000 (01:27 +0000)
CHANGES
lib/sqlalchemy/databases/mssql.py
test/engine/reflection.py

diff --git a/CHANGES b/CHANGES
index 2b7095f285c349e92a29b246bde6dc6e640ffeef..512e9bdd9235f265c642e14f651dc583c128c11b 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -23,6 +23,10 @@ CHANGES
     - Fixed E Notation issue that prevented the ability to
       insert decimal values less than 1E-6. [ticket:1216]
 
+    - Corrected problems with reflection when dealing with
+      schemas, particularly when those schemas are the
+      default schema. [ticket:1217]
+
 0.5.0rc3
 ========
 - features
index 73c9137883320bed8bd76425acad403acf8391dc..0ccad76ffadf00ccfda102ce2a80a8db7f7328e0 100644 (file)
@@ -682,10 +682,10 @@ class MSSQLDialect(default.DefaultDialect):
         rows = connection.execute(s).fetchall()
 
         def _gen_fkref(table, rschema, rtbl, rcol):
-            if table.schema and rschema != table.schema or rschema != current_schema:
-                return '.'.join([rschema, rtbl, rcol])
-            else:
+            if rschema == current_schema and not table.schema:
                 return '.'.join([rtbl, rcol])
+            else:
+                return '.'.join([rschema, rtbl, rcol])
 
         # group rows by constraint ID, to handle multi-column FKs
         fknm, scols, rcols = (None, [], [])
@@ -693,7 +693,7 @@ class MSSQLDialect(default.DefaultDialect):
             scol, rschema, rtbl, rcol, rfknm, fkmatch, fkuprule, fkdelrule = r
             # if the reflected schema is the default schema then don't set it because this will
             # play into the metadata key causing duplicates.
-            if rschema == current_schema:
+            if rschema == current_schema and not table.schema:
                 schema.Table(rtbl, table.metadata, autoload=True, autoload_with=connection)
             else:
                 schema.Table(rtbl, table.metadata, schema=rschema, autoload=True, autoload_with=connection)
index 7963cc0e4ad9fca419a6d5ab3aeefc5dadbd4329..e478e7c7a6d258cca5820926d1f927d0ce155621 100644 (file)
@@ -677,7 +677,7 @@ class SchemaTest(TestBase):
     @testing.crashes('firebird', 'No schema support')
     @testing.fails_on('sqlite')
     # fixme: revisit these below.
-    @testing.fails_on('access', 'mssql', 'sybase')
+    @testing.fails_on('access', 'sybase')
     def test_explicit_default_schema(self):
         engine = testing.db