]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- Fixed shard_id argument on ShardedSession.execute().
authorMike Bayer <mike_mp@zzzcomputing.com>
Sun, 28 Dec 2008 20:06:50 +0000 (20:06 +0000)
committerMike Bayer <mike_mp@zzzcomputing.com>
Sun, 28 Dec 2008 20:06:50 +0000 (20:06 +0000)
[ticket:1072]

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

diff --git a/CHANGES b/CHANGES
index 88e316ae7eea43783fb81ce898e006fc8439b253..2440cf575b111f63b75d78fd7383c87012d0438e 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -26,6 +26,9 @@ CHANGES
     
     - Class-bound accessor can be used as the argument to 
       relation() order_by.  [ticket:939]
+
+    - Fixed shard_id argument on ShardedSession.execute().
+      [ticket:1072]
       
 - sql
     - Connection.invalidate() checks for closed status 
index 9efe52d847f34bddbbed84f9768d6aa6e83a9cd2..d1c648616a3944c301ffc62812febeccabf787ad 100644 (file)
@@ -601,7 +601,7 @@ class Session(object):
         else:
             return engine.contextual_connect(**kwargs)
 
-    def execute(self, clause, params=None, mapper=None, instance=None):
+    def execute(self, clause, params=None, mapper=None, instance=None, **kw):
         """Execute the given clause, using the current transaction (if any).
 
         Returns a ``ResultProxy`` corresponding to the execution's results.
@@ -621,9 +621,14 @@ class Session(object):
         instance
             used by some Query operations to further identify
             the proper bind, in the case of ShardedSession.
+
+        \**kw
+          Additional keyword arguments are sent to ``get_bind()``
+          which locates a connectable to use for the execution.
+          Subclasses of ``Session`` may override this.
             
         """
-        engine = self.get_bind(mapper, clause=clause, instance=instance)
+        engine = self.get_bind(mapper, clause=clause, instance=instance, **kw)
 
         return self.__connection(engine, close_with_result=True).execute(clause, params or {})
 
index d231b14a2ce8ffacc626f2083490ae28d860ce72..584179474676df40d2372400ba2de7ed6305b6a6 100644 (file)
@@ -144,6 +144,7 @@ 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')]
+        assert sess.execute(weather_locations.select(), shard_id='asia').fetchall() == [(1, 'Asia', 'Tokyo')]
 
         t = sess.query(WeatherLocation).get(tokyo.id)
         assert t.city == tokyo.city