]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- fixed "double iter()" call causing bus errors
authorMike Bayer <mike_mp@zzzcomputing.com>
Thu, 27 Nov 2008 15:59:34 +0000 (15:59 +0000)
committerMike Bayer <mike_mp@zzzcomputing.com>
Thu, 27 Nov 2008 15:59:34 +0000 (15:59 +0000)
in shard API, removed errant result.close()
left over from the 0.4 version. [ticket:1099]
[ticket:1228]

CHANGES
lib/sqlalchemy/orm/shard.py
test/orm/sharding/shard.py

diff --git a/CHANGES b/CHANGES
index 9a0c1868d3fdb3b4bc79d4b37a5348df6485d6be..f562f2cdea647533f5b56a8dd0b9f3aa2aa50da7 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -44,6 +44,11 @@ CHANGES
       RelationProperty, to be consistent
       with all the other names.  PropertyLoader is 
       still present as a synonym.
+    
+    - fixed "double iter()" call causing bus errors
+      in shard API, removed errant result.close()
+      left over from the 0.4 version. [ticket:1099]
+      [ticket:1228]
       
 - sql
     - Fixed the import weirdness in sqlalchemy.sql
index 395d87dbfe219f3eb0fbed478dba4e043abe002c..f769b206f4d77dd4eb270aea6ab876f6524a7046 100644 (file)
@@ -94,18 +94,12 @@ class ShardedQuery(Query):
     def _execute_and_instances(self, context):
         if self._shard_id is not None:
             result = self.session.connection(mapper=self._mapper_zero(), shard_id=self._shard_id).execute(context.statement, self._params)
-            try:
-                return iter(self.instances(result, context))
-            finally:
-                result.close()
+            return self.instances(result, context)
         else:
             partial = []
             for shard_id in self.query_chooser(self):
                 result = self.session.connection(mapper=self._mapper_zero(), shard_id=shard_id).execute(context.statement, self._params)
-                try:
-                    partial = partial + list(self.instances(result, context))
-                finally:
-                    result.close()
+                partial = partial + list(self.instances(result, context))
             # if some kind of in memory 'sorting' were done, this is where it would happen
             return iter(partial)
 
index bd8b233c45ce319528af80b6d97925b643b01ae8..f25d097fd7624810f1a24645a7283dbccf617d25 100644 (file)
@@ -145,10 +145,9 @@ class ShardTest(TestBase):
         assert db2.execute(weather_locations.select()).fetchall() == [(1, 'Asia', 'Tokyo')]
         assert db1.execute(weather_locations.select()).fetchall() == [(2, 'North America', 'New York'), (3, 'North America', 'Toronto')]
 
-        # TODO: bus errors on some platforms, ticket #1099
-#        t = sess.query(WeatherLocation).get(tokyo.id)
-#        assert t.city == tokyo.city
-#        assert t.reports[0].temperature == 80.0
+        t = sess.query(WeatherLocation).get(tokyo.id)
+        assert t.city == tokyo.city
+        assert t.reports[0].temperature == 80.0
 
         north_american_cities = sess.query(WeatherLocation).filter(WeatherLocation.continent == 'North America')
         assert set([c.city for c in north_american_cities]) == set(['New York', 'Toronto'])