MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / _annotate_local

Method _annotate_local

lib/sqlalchemy/orm/relationships.py:2921–2949  ·  view source on GitHub ↗

Annotate the primaryjoin and secondaryjoin structures with 'local' annotations. This annotates all column elements found simultaneously in the parent table and the join condition that don't have a 'remote' annotation set up from _annotate_remote() or

(self)

Source from the content-addressed store, hash-verified

2919 )
2920
2921 def _annotate_local(self) -> None:
2922 """Annotate the primaryjoin and secondaryjoin
2923 structures with 'local' annotations.
2924
2925 This annotates all column elements found
2926 simultaneously in the parent table
2927 and the join condition that don't have a
2928 'remote' annotation set up from
2929 _annotate_remote() or user-defined.
2930
2931 """
2932 if self._has_annotation(self.primaryjoin, "local"):
2933 return
2934
2935 if self._local_remote_pairs:
2936 local_side = util.column_set(
2937 [l for (l, r) in self._local_remote_pairs]
2938 )
2939 else:
2940 local_side = util.column_set(self.parent_persist_selectable.c)
2941
2942 def locals_(element: _CE, **kw: Any) -> Optional[_CE]:
2943 if "remote" not in element._annotations and element in local_side:
2944 return element._annotate({"local": True})
2945 return None
2946
2947 self.primaryjoin = visitors.replacement_traverse(
2948 self.primaryjoin, {}, locals_
2949 )
2950
2951 def _annotate_parentmapper(self) -> None:
2952 def parentmappers_(element: _CE, **kw: Any) -> Optional[_CE]:

Callers 1

__init__Method · 0.95

Calls 1

_has_annotationMethod · 0.95

Tested by

no test coverage detected