1. idank
  2. sqlalchemy


Michael Trier  committed 17cfa4d

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.

  • Participants
  • Parent commits 5d76044
  • Branches default

Comments (0)

Files changed (2)

File lib/sqlalchemy/databases/mssql.py

View file
  • Ignore whitespace
                 if a is not None:
             coltype = self.ischema_names.get(type, None)
-            if coltype == MSString and charlen == -1:
+            if coltype == MSText or (coltype == MSString and charlen == -1):
                 coltype = MSText()
                 if coltype is None:
         # 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]:
         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)

File test/engine/reflection.py

View file
  • Ignore whitespace
             bind = engines.utf8_engine(options={'convert_unicode':True})
             metadata = MetaData(bind)
-            if testing.against('sybase', 'maxdb', 'oracle'):
+            if testing.against('sybase', 'maxdb', 'oracle', 'mssql'):
                 names = set(['plain'])
                 names = set([u'plain', u'Unit\u00e9ble', u'\u6e2c\u8a66'])