summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/orm/attributes.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2021-05-10 13:19:14 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2021-05-10 15:00:41 -0400
commitf0fc47c11986a0fa60b24c0fb62bd8b5a5306edd (patch)
treee5669d5eea2671a39b8596f8e89ee17f84341267 /lib/sqlalchemy/orm/attributes.py
parent17306220498cea779f360d03eeb5aadac3ccb59f (diff)
downloadsqlalchemy-f0fc47c11986a0fa60b24c0fb62bd8b5a5306edd.tar.gz
Correct cache key for proxy_owner, with_context_options
Fixed issue in subquery loader strategy which prevented caching from working correctly. This would have been seen in the logs as a "generated" message instead of "cached" for all subqueryload SQL emitted, which by saturating the cache with new keys would degrade overall performance; it also would produce "LRU size alert" warnings. In this issue we also observe that the local LRU cache for lazyloader and selectinloader will get used for all subsequent loads as well, which makes it more likely to hit the limit of 30. However rather than trying to work this out, it would be better if we removed the loader-local LRU caches altogether once we are confident these are working well. Fixes: #6459 Change-Id: Id953e8f75536bb87f7e3315929cebcd8f84a5a50
Diffstat (limited to 'lib/sqlalchemy/orm/attributes.py')
-rw-r--r--lib/sqlalchemy/orm/attributes.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/sqlalchemy/orm/attributes.py b/lib/sqlalchemy/orm/attributes.py
index 2f8c8f940..05b12dda2 100644
--- a/lib/sqlalchemy/orm/attributes.py
+++ b/lib/sqlalchemy/orm/attributes.py
@@ -227,7 +227,7 @@ class QueryableAttribute(
else:
annotations = {
"proxy_key": self.key,
- "proxy_owner": self.class_,
+ "proxy_owner": self._parententity,
"entity_namespace": self._entity_namespace,
}
@@ -533,6 +533,10 @@ def create_proxied_attribute(descriptor):
)
@property
+ def _parententity(self):
+ return inspection.inspect(self.class_, raiseerr=False)
+
+ @property
def _entity_namespace(self):
if hasattr(self._comparator, "_parententity"):
return self._comparator._parententity