From: Mike Bayer Date: Thu, 27 Nov 2008 15:59:34 +0000 (+0000) Subject: - fixed "double iter()" call causing bus errors X-Git-Tag: rel_0_5_0~153 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=181424b743ba59ec2b6631b4d914df136757d2fd;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git - 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] --- diff --git a/CHANGES b/CHANGES index 9a0c1868d3..f562f2cdea 100644 --- 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 diff --git a/lib/sqlalchemy/orm/shard.py b/lib/sqlalchemy/orm/shard.py index 395d87dbfe..f769b206f4 100644 --- a/lib/sqlalchemy/orm/shard.py +++ b/lib/sqlalchemy/orm/shard.py @@ -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) diff --git a/test/orm/sharding/shard.py b/test/orm/sharding/shard.py index bd8b233c45..f25d097fd7 100644 --- a/test/orm/sharding/shard.py +++ b/test/orm/sharding/shard.py @@ -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'])