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/orm/loading.py | |
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/orm/loading.py')
-rw-r--r-- | lib/sqlalchemy/orm/loading.py | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/lib/sqlalchemy/orm/loading.py b/lib/sqlalchemy/orm/loading.py index 1728b2d37..a169845d4 100644 --- a/lib/sqlalchemy/orm/loading.py +++ b/lib/sqlalchemy/orm/loading.py @@ -177,19 +177,21 @@ def load_on_ident(query, key, if key is not None: ident = key[1] + identity_token = key[2] else: - ident = None + ident = identity_token = None return load_on_pk_identity( query, ident, refresh_state=refresh_state, with_for_update=with_for_update, - only_load_props=only_load_props + only_load_props=only_load_props, + identity_token=identity_token ) def load_on_pk_identity(query, primary_key_identity, refresh_state=None, with_for_update=None, - only_load_props=None): + only_load_props=None, identity_token=None): """Load the given primary key identity from the database.""" @@ -240,7 +242,8 @@ def load_on_pk_identity(query, primary_key_identity, populate_existing=bool(refresh_state), version_check=version_check, only_load_props=only_load_props, - refresh_state=refresh_state) + refresh_state=refresh_state, + identity_token=identity_token) q._order_by = None try: |