]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
fix mssql cursor closed issue on reflection
authorRandall Smith <randall@tnr.cc>
Thu, 30 Apr 2009 04:23:20 +0000 (04:23 +0000)
committerRandall Smith <randall@tnr.cc>
Thu, 30 Apr 2009 04:23:20 +0000 (04:23 +0000)
lib/sqlalchemy/dialects/mssql/base.py

index 3baf7b3a084239baef928aa84e78578090b5ddc6..cfaf614890666ad2d365dcf8c24f63a6c5cd1b1f 100644 (file)
@@ -1179,6 +1179,7 @@ class MSDialect(default.DefaultDialect):
         view_names = [r[0] for r in connection.execute(s)]
         return view_names
 
+    # The cursor reports it is closed after executing the sp.
     @reflection.cache
     def get_indexes(self, connection, tablename, schema=None, **kw):
         current_schema = schema or self.get_default_schema_name(connection)
@@ -1186,6 +1187,9 @@ class MSDialect(default.DefaultDialect):
         indexes = []
         s = sql.text("exec sp_helpindex '%s'" % full_tname)
         rp = connection.execute(s)
+        if rp.closed:
+            # did not work for this setup.
+            return []
         for row in rp:
             if 'primary key' not in row['index_description']:
                 indexes.append({