diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2021-04-30 11:54:52 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2021-04-30 12:35:28 -0400 |
commit | a47c158a9a3b1104698fc0bff47ca58d67cb9191 (patch) | |
tree | dd6400edf840c1c628ebbb25af1c118fd5c58835 /lib/sqlalchemy/sql/lambdas.py | |
parent | a7157b29ba5830dd8f8a20e8df62eb9d56f6c759 (diff) | |
download | sqlalchemy-a47c158a9a3b1104698fc0bff47ca58d67cb9191.tar.gz |
track_on needs to be a fixed size, support sub-tuples
Fixed regression in ``selectinload`` loader strategy that would cause it to
cache its internal state incorrectly when handling relationships that join
across more than one column, such as when using a composite foreign key.
The invalid caching would then cause other loader operations to fail.
Fixes: #6410
Change-Id: I9f95ccca3553e7fd5794c619be4cf85c02b04626
Diffstat (limited to 'lib/sqlalchemy/sql/lambdas.py')
-rw-r--r-- | lib/sqlalchemy/sql/lambdas.py | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/sqlalchemy/sql/lambdas.py b/lib/sqlalchemy/sql/lambdas.py index 06db8f95e..ddc4774db 100644 --- a/lib/sqlalchemy/sql/lambdas.py +++ b/lib/sqlalchemy/sql/lambdas.py @@ -772,7 +772,16 @@ class AnalyzedCode(object): from the "track_on" parameter passed to a :class:`.LambdaElement`. """ - if isinstance(elem, traversals.HasCacheKey): + + if isinstance(elem, tuple): + # tuple must contain hascachekey elements + def get(closure, opts, anon_map, bindparams): + return tuple( + tup_elem._gen_cache_key(anon_map, bindparams) + for tup_elem in opts.track_on[idx] + ) + + elif isinstance(elem, traversals.HasCacheKey): def get(closure, opts, anon_map, bindparams): return opts.track_on[idx]._gen_cache_key(anon_map, bindparams) |