diff options
author | Michael Trier <mtrier@gmail.com> | 2008-10-11 16:14:07 +0000 |
---|---|---|
committer | Michael Trier <mtrier@gmail.com> | 2008-10-11 16:14:07 +0000 |
commit | b3c39decc1b992bcb7c1bb7cad452dcea5991f20 (patch) | |
tree | 80023d0e3017bb8f449bd5e62f3ac2441412403d /lib/sqlalchemy/databases/mssql.py | |
parent | 188a990e221c7a84c350886dd699ce3f01932b8c (diff) | |
download | sqlalchemy-b3c39decc1b992bcb7c1bb7cad452dcea5991f20.tar.gz |
Correction of mssql schema reflection in reflectable. Still a problem since the assumed default is dbo, whereas it could be modified by the connection. Allows SchemaTest.test_select to pass now.
Diffstat (limited to 'lib/sqlalchemy/databases/mssql.py')
-rw-r--r-- | lib/sqlalchemy/databases/mssql.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/sqlalchemy/databases/mssql.py b/lib/sqlalchemy/databases/mssql.py index 5f4f5a374..8bf8144cf 100644 --- a/lib/sqlalchemy/databases/mssql.py +++ b/lib/sqlalchemy/databases/mssql.py @@ -545,7 +545,6 @@ class MSSQLDialect(default.DefaultDialect): def reflecttable(self, connection, table, include_columns): import sqlalchemy.databases.information_schema as ischema - # Get base columns if table.schema is not None: current_schema = table.schema @@ -669,7 +668,12 @@ class MSSQLDialect(default.DefaultDialect): fknm, scols, rcols = (None, [], []) for r in rows: scol, rschema, rtbl, rcol, rfknm, fkmatch, fkuprule, fkdelrule = r - schema.Table(rtbl, table.metadata, schema=rschema, autoload=True, autoload_with=connection) + # 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: + schema.Table(rtbl, table.metadata, autoload=True, autoload_with=connection) + else: + schema.Table(rtbl, table.metadata, schema=rschema, autoload=True, autoload_with=connection) if rfknm != fknm: if fknm: table.append_constraint(schema.ForeignKeyConstraint(scols, [_gen_fkref(table, s, t, c) for s, t, c in rcols], fknm)) |