diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2018-05-16 11:16:57 -0400 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2018-05-16 15:41:32 -0400 |
| commit | 3fa38a1a2313b4644daa431d629394d6bb14497a (patch) | |
| tree | a4028ff0649a0c1cd55b579035eaa80bbc649cba /lib/sqlalchemy/ext | |
| parent | 432d24ab1aac04a8ec881919964ff47ad8154659 (diff) | |
| download | sqlalchemy-3fa38a1a2313b4644daa431d629394d6bb14497a.tar.gz | |
Change query._identity_lookup into a normal instance method
Fixed regression in 1.2.7 caused by :ticket:`4228`, which itself was fixing
a 1.2-level regression, where the ``query_cls`` callable passed to a
:class:`.Session` was assumed to be a subclass of :class:`.Query` with
class method availability, as opposed to an arbitrary callable. In
particular, the dogpile caching example illustrates ``query_cls`` as a
function and not a :class:`.Query` subclass.
Change-Id: I3f86fcb12a6a9a89aa308b335e75c25969bcc30e
Fixes: #4256
Diffstat (limited to 'lib/sqlalchemy/ext')
| -rw-r--r-- | lib/sqlalchemy/ext/horizontal_shard.py | 21 |
1 files changed, 8 insertions, 13 deletions
diff --git a/lib/sqlalchemy/ext/horizontal_shard.py b/lib/sqlalchemy/ext/horizontal_shard.py index 6516950ed..c7770d195 100644 --- a/lib/sqlalchemy/ext/horizontal_shard.py +++ b/lib/sqlalchemy/ext/horizontal_shard.py @@ -64,10 +64,8 @@ class ShardedQuery(Query): # were done, this is where it would happen return iter(partial) - @classmethod def _identity_lookup( - cls, session, mapper, primary_key_identity, identity_token=None, - **kw): + self, mapper, primary_key_identity, identity_token=None, **kw): """override the default Query._identity_lookup method so that we search for a given non-token primary key identity across all possible identity tokens (e.g. shard ids). @@ -75,18 +73,15 @@ class ShardedQuery(Query): """ if identity_token is not None: - return super(ShardedQuery, cls)._identity_lookup( - session, mapper, primary_key_identity, - identity_token=identity_token, - **kw + return super(ShardedQuery, self)._identity_lookup( + mapper, primary_key_identity, + identity_token=identity_token, **kw ) else: - q = cls([mapper], session) - for shard_id in q.id_chooser(q, primary_key_identity): - obj = super(ShardedQuery, cls)._identity_lookup( - session, mapper, primary_key_identity, - identity_token=shard_id, - **kw + q = self.session.query(mapper) + for shard_id in self.id_chooser(q, primary_key_identity): + obj = super(ShardedQuery, self)._identity_lookup( + mapper, primary_key_identity, identity_token=shard_id, **kw ) if obj is not None: return obj |
