MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / _join

Method _join

lib/sqlalchemy/orm/context.py:1907–1998  ·  lib/sqlalchemy/orm/context.py::_ORMSelectCompileState._join
(self, args, entities_collection)

Source from the content-addressed store, hash-verified

1905 return _adapt_clause
1906
1907 def _join(self, args, entities_collection):
1908 for right, onclause, from_, flags in args:
1909 isouter = flags[class="st">"isouter"]
1910 full = flags[class="st">"full"]
1911
1912 right = inspect(right)
1913 if onclause is not None:
1914 onclause = inspect(onclause)
1915
1916 if isinstance(right, interfaces.PropComparator):
1917 if onclause is not None:
1918 raise sa_exc.InvalidRequestError(
1919 class="st">"No &class="cm">#x27;on clause' argument may be passed when joining "
1920 class="st">"to a relationship path as a target"
1921 )
1922
1923 onclause = right
1924 right = None
1925 elif class="st">"parententity" in right._annotations:
1926 right = right._annotations[class="st">"parententity"]
1927
1928 if onclause is None:
1929 if not right.is_selectable and not hasattr(right, class="st">"mapper"):
1930 raise sa_exc.ArgumentError(
1931 class="st">"Expected mapped entity or "
1932 class="st">"selectable/table as join target"
1933 )
1934
1935 if isinstance(onclause, interfaces.PropComparator):
1936 class="cm"># descriptor/property given (or determined); this tells us
1937 class="cm"># explicitly what the expected class="st">"left" side of the join is.
1938
1939 of_type = getattr(onclause, class="st">"_of_type", None)
1940
1941 if right is None:
1942 if of_type:
1943 right = of_type
1944 else:
1945 right = onclause.property
1946
1947 try:
1948 right = right.entity
1949 except AttributeError as err:
1950 raise sa_exc.ArgumentError(
1951 class="st">"Join target %s does not refer to a "
1952 class="st">"mapped entity" % right
1953 ) from err
1954
1955 left = onclause._parententity
1956
1957 prop = onclause.property
1958 if not isinstance(onclause, attributes.QueryableAttribute):
1959 onclause = prop
1960
1961 class="cm"># check for this path already present. don't render in that
1962 class="cm"># case.
1963 if (left, right, prop.key) in self._already_joined_edges:
1964 continue

Callers 1

_setup_for_generateMethod · 0.95

Calls 3

_join_left_to_rightMethod · 0.95
inspectFunction · 0.90
getMethod · 0.45

Tested by

no test coverage detected