prop = None
on_selectable = None
+ left_selectable = left_info.selectable
if prop:
- left_selectable = left_info.selectable
adapt_from: Optional[FromClause]
if sql_util.clause_is_present(on_selectable, left_selectable):
adapt_from = on_selectable
self._target_adapter = target_adapter
- # we don't use the normal coercions logic for _ORMJoin
- # (probably should), so do some gymnastics to get the entity.
- # logic here is for #8721, which was a major bug in 1.4
- # for almost two years, not reported/fixed until 1.4.43 (!)
- if is_selectable(left_info):
- parententity = left_selectable._annotations.get(
- "parententity", None
- )
- elif insp_is_mapper(left_info) or insp_is_aliased_class(left_info):
- parententity = left_info
- else:
- parententity = None
+ # we don't use the normal coercions logic for _ORMJoin
+ # (probably should), so do some gymnastics to get the entity.
+ # logic here is for #8721, which was a major bug in 1.4
+ # for almost two years, not reported/fixed until 1.4.43 (!)
+ if is_selectable(left_info):
+ parententity = left_selectable._annotations.get(
+ "parententity", None
+ )
+ elif insp_is_mapper(left_info) or insp_is_aliased_class(left_info):
+ parententity = left_info
+ else:
+ parententity = None
- if parententity is not None:
- self._annotations = self._annotations.union(
- {"parententity": parententity}
- )
+ if parententity is not None:
+ self._annotations = self._annotations.union(
+ {"parententity": parententity}
+ )
- augment_onclause = onclause is None and _extra_criteria
+ augment_onclause = bool(_extra_criteria) and not prop
expression.Join.__init__(self, left, right, onclause, isouter, full)
assert self.onclause is not None
.join(User.addresses)
.options(with_loader_criteria(User, User.name != "name")),
),
+ (
+ # issue #10365
+ lambda User, Address: select(Address)
+ .select_from(User)
+ .join(Address, User.id == Address.user_id)
+ .options(with_loader_criteria(User, User.name != "name")),
+ ),
(
lambda User, Address: select(Address)
.select_from(orm_join(User, Address, User.addresses))
.join(User.addresses)
.options(with_loader_criteria(User, User.name != "name")),
),
+ (
+ # issue #10365 - this seems to have already worked
+ lambda User, Address: select(Address.id, User.id)
+ .select_from(User)
+ .join(Address, User.id == Address.user_id)
+ .options(with_loader_criteria(User, User.name != "name")),
+ ),
(
lambda User, Address: select(Address.id, User.id)
.select_from(orm_join(User, Address, User.addresses))
with_loader_criteria(Address, Address.email_address != "email")
),
),
+ (
+ # issue #10365
+ lambda User, Address: select(Address)
+ .select_from(User)
+ .join(Address, User.id == Address.user_id)
+ .options(
+ with_loader_criteria(Address, Address.email_address != "email")
+ ),
+ ),
(
# for orm_join(), this is set up before we have the context
# available that allows with_loader_criteria to be set up