diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2018-05-03 12:35:23 -0400 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2018-05-03 12:35:23 -0400 |
| commit | 4b71933489cae21ad94b71b0bc7271c075ad0dda (patch) | |
| tree | 6206ad2828b1512e4da7066b7df09aa141603873 /lib/sqlalchemy/ext | |
| parent | 67fe179d1b2fb559b213d2e924da365f05e169ce (diff) | |
| download | sqlalchemy-4b71933489cae21ad94b71b0bc7271c075ad0dda.tar.gz | |
Use identity_token for refresh(), unexpire, undefer
The horizontal sharding extension now makes use of the identity token
added to ORM identity keys as part of :ticket:`4137`, when an object
refresh or column-based deferred load or unexpiration operation occurs.
Since we know the "shard" that the object originated from, we make
use of this value when refreshing, thereby avoiding queries against
other shards that don't match this object's identity in any case.
Change-Id: Ib91637a65d94ace7405998b8410d62944a83f2eb
Fixes: #4247
Diffstat (limited to 'lib/sqlalchemy/ext')
| -rw-r--r-- | lib/sqlalchemy/ext/horizontal_shard.py | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/sqlalchemy/ext/horizontal_shard.py b/lib/sqlalchemy/ext/horizontal_shard.py index 266bd784e..6516950ed 100644 --- a/lib/sqlalchemy/ext/horizontal_shard.py +++ b/lib/sqlalchemy/ext/horizontal_shard.py @@ -51,7 +51,9 @@ class ShardedQuery(Query): self._params) return self.instances(result, context) - if self._shard_id is not None: + if context.identity_token is not None: + return iter_for_shard(context.identity_token) + elif self._shard_id is not None: return iter_for_shard(self._shard_id) else: partial = [] |
