]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
Corrected problem with detecting closed connections. Fixed issues in reflecttable...
authorMichael Trier <mtrier@gmail.com>
Wed, 23 Jul 2008 05:10:04 +0000 (05:10 +0000)
committerMichael Trier <mtrier@gmail.com>
Wed, 23 Jul 2008 05:10:04 +0000 (05:10 +0000)
lib/sqlalchemy/databases/mssql.py
test/engine/reflection.py

index 5852b2c434d8f68cb84ba6a64dffeb134648a137..0341d182307c90307b746580a99dcf9df335ba7b 100644 (file)
@@ -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)
index 3f8d4fff7495729ac5dec6a555a835bad4e3e2b0..873c05aa53c5a2548ff9f79d48c72424540e445e 100644 (file)
@@ -618,7 +618,7 @@ class UnicodeReflectionTest(TestBase):
             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'])
             else:
                 names = set([u'plain', u'Unit\u00e9ble', u'\u6e2c\u8a66'])