MCPcopy
hub / github.com/pyrevitlabs/pyRevit / _ORMJoin

Class _ORMJoin

site-packages/sqlalchemy/orm/util.py:787–894  ·  view source on GitHub ↗

Extend Join to support ORM constructs as input.

Source from the content-addressed store, hash-verified

785
786
787class _ORMJoin(expression.Join):
788 """Extend Join to support ORM constructs as input."""
789
790 __visit_name__ = expression.Join.__visit_name__
791
792 def __init__(
793 self,
794 left, right, onclause=None, isouter=False,
795 full=False, _left_memo=None, _right_memo=None):
796
797 left_info = inspection.inspect(left)
798 left_orm_info = getattr(left, '_joined_from_info', left_info)
799
800 right_info = inspection.inspect(right)
801 adapt_to = right_info.selectable
802
803 self._joined_from_info = right_info
804
805 self._left_memo = _left_memo
806 self._right_memo = _right_memo
807
808 if isinstance(onclause, util.string_types):
809 onclause = getattr(left_orm_info.entity, onclause)
810
811 if isinstance(onclause, attributes.QueryableAttribute):
812 on_selectable = onclause.comparator._source_selectable()
813 prop = onclause.property
814 elif isinstance(onclause, MapperProperty):
815 prop = onclause
816 on_selectable = prop.parent.selectable
817 else:
818 prop = None
819
820 if prop:
821 if sql_util.clause_is_present(
822 on_selectable, left_info.selectable):
823 adapt_from = on_selectable
824 else:
825 adapt_from = left_info.selectable
826
827 pj, sj, source, dest, \
828 secondary, target_adapter = prop._create_joins(
829 source_selectable=adapt_from,
830 dest_selectable=adapt_to,
831 source_polymorphic=True,
832 dest_polymorphic=True,
833 of_type=right_info.mapper)
834
835 if sj is not None:
836 if isouter:
837 # note this is an inner join from secondary->right
838 right = sql.join(secondary, right, sj)
839 onclause = pj
840 else:
841 left = sql.join(left, secondary, pj, isouter)
842 onclause = sj
843 else:
844 onclause = pj

Callers 5

_splice_into_centerMethod · 0.85
joinMethod · 0.85
outerjoinMethod · 0.85
joinFunction · 0.85
outerjoinFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected