diff options
Diffstat (limited to 'lib/sqlalchemy')
| -rw-r--r-- | lib/sqlalchemy/orm/relationships.py | 20 | ||||
| -rw-r--r-- | lib/sqlalchemy/orm/strategies.py | 1 |
2 files changed, 20 insertions, 1 deletions
diff --git a/lib/sqlalchemy/orm/relationships.py b/lib/sqlalchemy/orm/relationships.py index a8013f36d..aa49b8c7c 100644 --- a/lib/sqlalchemy/orm/relationships.py +++ b/lib/sqlalchemy/orm/relationships.py @@ -817,7 +817,16 @@ class RelationshipProperty(StrategizedProperty): :param omit_join: Allows manual control over the "selectin" automatic join optimization. Set to ``False`` to disable the "omit join" feature - added in SQLAlchemy 1.3. + added in SQLAlchemy 1.3; or leave as ``None`` to leave automatic + optimization in place. + + .. note:: This flag may only be set to ``False``. It is not + necessary to set it to ``True`` as the "omit_join" optimization is + automatically detected; if it is not detected, then the + optimization is not supported. + + .. versionchanged:: 1.3.11 setting ``omit_join`` to True will now + emit a warning as this was not the intended use of this flag. .. versionadded:: 1.3 @@ -848,6 +857,15 @@ class RelationshipProperty(StrategizedProperty): self.doc = doc self.active_history = active_history self.join_depth = join_depth + if omit_join: + util.warn( + "setting omit_join to True is not supported; selectin " + "loading of this relationship may not work correctly if this " + "flag is set explicitly. omit_join optimization is " + "automatically detected for conditions under which it is " + "supported." + ) + self.omit_join = omit_join self.local_remote_pairs = _local_remote_pairs self.bake_queries = bake_queries diff --git a/lib/sqlalchemy/orm/strategies.py b/lib/sqlalchemy/orm/strategies.py index 59877a521..44ef43418 100644 --- a/lib/sqlalchemy/orm/strategies.py +++ b/lib/sqlalchemy/orm/strategies.py @@ -2167,6 +2167,7 @@ class SelectInLoader(PostLoader, util.MemoizedSlots): use_proxies=True, equivalents=self.parent._equivalent_columns, ) + if self.omit_join: if is_m2o: self._query_info = self._init_for_omit_join_m2o() |
