summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/orm/interfaces.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2021-12-08 20:27:16 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2021-12-27 12:30:38 -0500
commit91501e06a17d873902114275d7149ba24973db6a (patch)
tree464d2c7167c30d92be13c851b52c0f4471645456 /lib/sqlalchemy/orm/interfaces.py
parent2bb6cfc7c9b8f09eaa4efeffc337a1162993979c (diff)
downloadsqlalchemy-91501e06a17d873902114275d7149ba24973db6a.tar.gz
factor out UnboundLoad and rearchitect strategy_options.py
The architecture of Load is mostly rewritten here. The change includes removal of the "pluggable" aspect of the loader options, which would patch new methods onto Load. This has been replaced by normal methods that respond normally to typing annotations. As part of this change, the bake_loaders() and unbake_loaders() options, which have no effect since 1.4 and were unlikely to be in any common use, have been removed. Additionally, to support annotations for methods that make use of @decorator, @generative etc., modified format_argspec_plus to no longer return "args", instead returns "grouped_args" which is always grouped and allows return annotations to format correctly. Fixes: #6986 Change-Id: I6117c642345cdde65a64389bba6057ddd5374427
Diffstat (limited to 'lib/sqlalchemy/orm/interfaces.py')
-rw-r--r--lib/sqlalchemy/orm/interfaces.py40
1 files changed, 20 insertions, 20 deletions
diff --git a/lib/sqlalchemy/orm/interfaces.py b/lib/sqlalchemy/orm/interfaces.py
index 2c6818a93..92ecbdd2d 100644
--- a/lib/sqlalchemy/orm/interfaces.py
+++ b/lib/sqlalchemy/orm/interfaces.py
@@ -590,17 +590,13 @@ class StrategizedProperty(MapperProperty):
def _memoized_attr__wildcard_token(self):
return (
- "%s:%s"
- % (self.strategy_wildcard_key, path_registry._WILDCARD_TOKEN),
+ f"{self.strategy_wildcard_key}:{path_registry._WILDCARD_TOKEN}",
)
def _memoized_attr__default_path_loader_key(self):
return (
"loader",
- (
- "%s:%s"
- % (self.strategy_wildcard_key, path_registry._DEFAULT_TOKEN),
- ),
+ (f"{self.strategy_wildcard_key}:{path_registry._DEFAULT_TOKEN}",),
)
def _get_context_loader(self, context, path):
@@ -619,6 +615,13 @@ class StrategizedProperty(MapperProperty):
load = context.attributes[path_key]
break
+ # note that if strategy_options.Load is placing non-actionable
+ # objects in the context like defaultload(), we would
+ # need to continue the loop here if we got such an
+ # option as below.
+ # if load.strategy or load.local_opts:
+ # break
+
return load
def _get_strategy(self, key):
@@ -780,7 +783,13 @@ class CompileStateOption(HasCacheKey, ORMOption):
_is_compile_state = True
def process_compile_state(self, compile_state):
- """Apply a modification to a given :class:`.CompileState`."""
+ """Apply a modification to a given :class:`.CompileState`.
+
+ This method is part of the implementation of a particular
+ :class:`.CompileStateOption` and is only invoked internally
+ when an ORM query is compiled.
+
+ """
def process_compile_state_replaced_entities(
self, compile_state, mapper_entities
@@ -789,6 +798,10 @@ class CompileStateOption(HasCacheKey, ORMOption):
given entities that were replaced by with_only_columns() or
with_entities().
+ This method is part of the implementation of a particular
+ :class:`.CompileStateOption` and is only invoked internally
+ when an ORM query is compiled.
+
.. versionadded:: 1.4.19
"""
@@ -804,18 +817,8 @@ class LoaderOption(CompileStateOption):
def process_compile_state_replaced_entities(
self, compile_state, mapper_entities
):
- """Apply a modification to a given :class:`.CompileState`,
- given entities that were replaced by with_only_columns() or
- with_entities().
-
- .. versionadded:: 1.4.19
-
- """
self.process_compile_state(compile_state)
- def process_compile_state(self, compile_state):
- """Apply a modification to a given :class:`.CompileState`."""
-
class CriteriaOption(CompileStateOption):
"""Describe a WHERE criteria modification to an ORM statement at
@@ -827,9 +830,6 @@ class CriteriaOption(CompileStateOption):
_is_criteria_option = True
- def process_compile_state(self, compile_state):
- """Apply a modification to a given :class:`.CompileState`."""
-
def get_global_criteria(self, attributes):
"""update additional entity criteria options in the given
attributes dictionary.