Create a join condition between two tables or selectables. e.g.:: join_condition(tablea, tableb) would produce an expression along the lines of:: tablea.c.id == tableb.c.tablea_id The join is determined based on the foreign key relationships between the two selec
(
a: FromClause,
b: FromClause,
a_subset: Optional[FromClause] = None,
consider_as_foreign_keys: Optional[AbstractSet[ColumnClause[Any]]] = None,
)
| 93 | |
| 94 | |
| 95 | def join_condition( |
| 96 | a: FromClause, |
| 97 | b: FromClause, |
| 98 | a_subset: Optional[FromClause] = None, |
| 99 | consider_as_foreign_keys: Optional[AbstractSet[ColumnClause[Any]]] = None, |
| 100 | ) -> ColumnElement[bool]: |
| 101 | """Create a join condition between two tables or selectables. |
| 102 | |
| 103 | e.g.:: |
| 104 | |
| 105 | join_condition(tablea, tableb) |
| 106 | |
| 107 | would produce an expression along the lines of:: |
| 108 | |
| 109 | tablea.c.id == tableb.c.tablea_id |
| 110 | |
| 111 | The join is determined based on the foreign key relationships |
| 112 | between the two selectables. If there are multiple ways |
| 113 | to join, or no way to join, an error is raised. |
| 114 | |
| 115 | :param a_subset: An optional expression that is a sub-component |
| 116 | of ``a``. An attempt will be made to join to just this sub-component |
| 117 | first before looking at the full ``a`` construct, and if found |
| 118 | will be successful even if there are other ways to join to ``a``. |
| 119 | This allows the "right side" of a join to be passed thereby |
| 120 | providing a "natural join". |
| 121 | |
| 122 | """ |
| 123 | return Join._join_condition( |
| 124 | a, |
| 125 | b, |
| 126 | a_subset=a_subset, |
| 127 | consider_as_foreign_keys=consider_as_foreign_keys, |
| 128 | ) |
| 129 | |
| 130 | |
| 131 | def find_join_source( |
no test coverage detected