diff options
author | Michael Trier <mtrier@gmail.com> | 2008-07-23 05:10:04 +0000 |
---|---|---|
committer | Michael Trier <mtrier@gmail.com> | 2008-07-23 05:10:04 +0000 |
commit | 951fe224fa5638e2c1c224f9ebfcaebb38e49922 (patch) | |
tree | 1964b051072965f978be06604e1e89cec1db2b0b /lib/sqlalchemy/databases/mssql.py | |
parent | cfb9bbde7da6fe2b145a49851dc2d6424941ef25 (diff) | |
download | sqlalchemy-951fe224fa5638e2c1c224f9ebfcaebb38e49922.tar.gz |
Corrected problem with detecting closed connections. Fixed issues in reflecttable for reflecting the mssql tables. Removed unicode reflection test from mssql. Need to investigate this further.
Diffstat (limited to 'lib/sqlalchemy/databases/mssql.py')
-rw-r--r-- | lib/sqlalchemy/databases/mssql.py | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/lib/sqlalchemy/databases/mssql.py b/lib/sqlalchemy/databases/mssql.py index 5852b2c43..0341d1823 100644 --- a/lib/sqlalchemy/databases/mssql.py +++ b/lib/sqlalchemy/databases/mssql.py @@ -582,7 +582,7 @@ class MSSQLDialect(default.DefaultDialect): if a is not None: args.append(a) coltype = self.ischema_names.get(type, None) - if coltype == MSString and charlen == -1: + if coltype == MSText or (coltype == MSString and charlen == -1): coltype = MSText() else: if coltype is None: @@ -639,7 +639,7 @@ class MSSQLDialect(default.DefaultDialect): # Primary key constraints s = sql.select([C.c.column_name, TC.c.constraint_type], sql.and_(TC.c.constraint_name == C.c.constraint_name, C.c.table_name == table.name, - C.c.table_schema == table.schema)) + C.c.table_schema == (table.schema or current_schema))) c = connection.execute(s) for row in c: if 'PRIMARY' in row[TC.c.constraint_type.name]: @@ -804,7 +804,12 @@ class MSSQLDialect_pyodbc(MSSQLDialect): return [[";".join (connectors)], {}] def is_disconnect(self, e): - return isinstance(e, self.dbapi.Error) and '[08S01]' in str(e) + if isinstance(e, self.dbapi.ProgrammingError): + return "The cursor's connection has been closed." in str(e) or 'Attempt to use a closed connection.' in str(e) + elif isinstance(e, self.dbapi.Error): + return '[08S01]' in str(e) + else: + return False def create_execution_context(self, *args, **kwargs): return MSSQLExecutionContext_pyodbc(self, *args, **kwargs) |