Extend Join to support ORM constructs as input.
| 1825 | |
| 1826 | |
| 1827 | class _ORMJoin(expression.Join): |
| 1828 | """Extend Join to support ORM constructs as input.""" |
| 1829 | |
| 1830 | __visit_name__ = expression.Join.__visit_name__ |
| 1831 | |
| 1832 | inherit_cache = True |
| 1833 | |
| 1834 | def __init__( |
| 1835 | self, |
| 1836 | left: _FromClauseArgument, |
| 1837 | right: _FromClauseArgument, |
| 1838 | onclause: Optional[_OnClauseArgument] = None, |
| 1839 | isouter: bool = False, |
| 1840 | full: bool = False, |
| 1841 | _left_memo: Optional[Any] = None, |
| 1842 | _right_memo: Optional[Any] = None, |
| 1843 | _extra_criteria: Tuple[ColumnElement[bool], ...] = (), |
| 1844 | ): |
| 1845 | left_info = cast( |
| 1846 | "Union[FromClause, _InternalEntityType[Any]]", |
| 1847 | inspection.inspect(left), |
| 1848 | ) |
| 1849 | |
| 1850 | right_info = cast( |
| 1851 | "Union[FromClause, _InternalEntityType[Any]]", |
| 1852 | inspection.inspect(right), |
| 1853 | ) |
| 1854 | adapt_to = right_info.selectable |
| 1855 | |
| 1856 | # used by joined eager loader |
| 1857 | self._left_memo = _left_memo |
| 1858 | self._right_memo = _right_memo |
| 1859 | |
| 1860 | if isinstance(onclause, attributes.QueryableAttribute): |
| 1861 | if TYPE_CHECKING: |
| 1862 | assert isinstance( |
| 1863 | onclause.comparator, RelationshipProperty.Comparator |
| 1864 | ) |
| 1865 | on_selectable = onclause.comparator._source_selectable() |
| 1866 | prop = onclause.property |
| 1867 | _extra_criteria += onclause._extra_criteria |
| 1868 | elif isinstance(onclause, MapperProperty): |
| 1869 | # used internally by joined eager loader...possibly not ideal |
| 1870 | prop = onclause |
| 1871 | on_selectable = prop.parent.selectable |
| 1872 | else: |
| 1873 | prop = None |
| 1874 | on_selectable = None |
| 1875 | |
| 1876 | left_selectable = left_info.selectable |
| 1877 | if prop: |
| 1878 | adapt_from: Optional[FromClause] |
| 1879 | if sql_util.clause_is_present(on_selectable, left_selectable): |
| 1880 | adapt_from = on_selectable |
| 1881 | else: |
| 1882 | assert isinstance(left_selectable, FromClause) |
| 1883 | adapt_from = left_selectable |
| 1884 |
no outgoing calls
no test coverage detected