MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / join_targets

Method join_targets

lib/sqlalchemy/orm/relationships.py:3339–3482  ·  view source on GitHub ↗

Given a source and destination selectable, create a join between them. This takes into account aliasing the join clause to reference the appropriate corresponding columns in the target objects, as well as the extra child criterion, equivalent column sets, etc

(
        self,
        source_selectable: Optional[FromClause],
        dest_selectable: FromClause,
        aliased: bool,
        single_crit: Optional[ColumnElement[bool]] = None,
        extra_criteria: Tuple[ColumnElement[bool], ...] = (),
    )

Source from the content-addressed store, hash-verified

3337 return util.EMPTY_SET
3338
3339 def join_targets(
3340 self,
3341 source_selectable: Optional[FromClause],
3342 dest_selectable: FromClause,
3343 aliased: bool,
3344 single_crit: Optional[ColumnElement[bool]] = None,
3345 extra_criteria: Tuple[ColumnElement[bool], ...] = (),
3346 ) -> Tuple[
3347 ColumnElement[bool],
3348 Optional[ColumnElement[bool]],
3349 Optional[FromClause],
3350 Optional[ClauseAdapter],
3351 FromClause,
3352 ]:
3353 """Given a source and destination selectable, create a
3354 join between them.
3355
3356 This takes into account aliasing the join clause
3357 to reference the appropriate corresponding columns
3358 in the target objects, as well as the extra child
3359 criterion, equivalent column sets, etc.
3360
3361 """
3362 # place a barrier on the destination such that
3363 # replacement traversals won't ever dig into it.
3364 # its internal structure remains fixed
3365 # regardless of context.
3366 dest_selectable = _shallow_annotate(
3367 dest_selectable, {"no_replacement_traverse": True}
3368 )
3369
3370 primaryjoin, secondaryjoin, secondary = (
3371 self.primaryjoin,
3372 self.secondaryjoin,
3373 self.secondary,
3374 )
3375
3376 # adjust the join condition for single table inheritance,
3377 # in the case that the join is to a subclass
3378 # this is analogous to the
3379 # "_adjust_for_single_table_inheritance()" method in Query.
3380
3381 if single_crit is not None:
3382 if secondaryjoin is not None:
3383 secondaryjoin = secondaryjoin & single_crit
3384 else:
3385 primaryjoin = primaryjoin & single_crit
3386
3387 if extra_criteria:
3388
3389 def mark_exclude_cols(
3390 elem: SupportsAnnotations, annotations: _AnnotationDict
3391 ) -> SupportsAnnotations:
3392 """note unrelated columns in the "extra criteria" as either
3393 should be adapted or not adapted, even though they are not
3394 part of our "local" or "remote" side.
3395
3396 see #9779 for this case, as well as #11010 for a follow up

Calls 7

traverseMethod · 0.95
_shallow_annotateFunction · 0.85
_deep_annotateFunction · 0.85
ClauseAdapterClass · 0.85
and_Method · 0.45
_anonymous_fromclauseMethod · 0.45
chainMethod · 0.45