]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- Fixed bug whereby metadata.reflect(bind)
authorMike Bayer <mike_mp@zzzcomputing.com>
Wed, 1 Jun 2011 21:46:17 +0000 (17:46 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Wed, 1 Jun 2011 21:46:17 +0000 (17:46 -0400)
    would close a Connection passed as a
    bind argument.  Regression from 0.6.

CHANGES
lib/sqlalchemy/schema.py
test/engine/test_reflection.py

diff --git a/CHANGES b/CHANGES
index a946f2cac6a5885243588fc77ed05ed362713b79..d68e586b55c25622cd91adf7dc7fd503dc14374f 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -7,6 +7,10 @@ CHANGES
 =====
 
 - sql
+  - Fixed bug whereby metadata.reflect(bind)
+    would close a Connection passed as a
+    bind argument.  Regression from 0.6.
+
   - Streamlined the process by which a Select
     determines what's in it's '.c' collection.
     Behaves identically, except that a 
index e85c82ad72970f175712029350a919ce5eaab369..511d922a0ab65edcdc7065d748d0d68ff1493b05 100644 (file)
@@ -2338,7 +2338,8 @@ class MetaData(SchemaItem):
             for name in load:
                 Table(name, self, **reflect_opts)
         finally:
-            if conn is not None:
+            if conn is not None and \
+                conn is not bind:
                 conn.close()
 
     def append_ddl_listener(self, event_name, listener):
index 023d7a3e24b16d444dbcc6fff1bed9d79a0ad009..5a684eaa50a43a591ef67c611fb5eab08b6cc531 100644 (file)
@@ -695,6 +695,18 @@ class ReflectionTest(fixtures.TestBase, ComparesTables):
             m9.reflect()
             self.assert_(not m9.tables)
 
+    def test_reflect_all_conn_closing(self):
+        m1 = MetaData()
+        c = testing.db.connect()
+        m1.reflect(bind=c)
+        assert not c.closed
+
+    def test_inspector_conn_closing(self):
+        m1 = MetaData()
+        c = testing.db.connect()
+        i = Inspector.from_engine(testing.db)
+        assert not c.closed
+
     def test_index_reflection(self):
         m1 = MetaData(testing.db)
         t1 = Table('party', m1,