r"""Create a SQL JOIN against this :class:`_expression.Select` object's criterion and apply generatively, returning the newly resulting :class:`_expression.Select`. E.g.:: stmt = select(user_table).join( address_table, user_table.c.id ==
(
self,
target: _JoinTargetArgument,
onclause: Optional[_OnClauseArgument] = None,
*,
isouter: bool = False,
full: bool = False,
)
| 5779 | |
| 5780 | @_generative |
| 5781 | def join( |
| 5782 | self, |
| 5783 | target: _JoinTargetArgument, |
| 5784 | onclause: Optional[_OnClauseArgument] = None, |
| 5785 | *, |
| 5786 | isouter: bool = False, |
| 5787 | full: bool = False, |
| 5788 | ) -> Self: |
| 5789 | r"""Create a SQL JOIN against this :class:`_expression.Select` |
| 5790 | object's criterion |
| 5791 | and apply generatively, returning the newly resulting |
| 5792 | :class:`_expression.Select`. |
| 5793 | |
| 5794 | E.g.:: |
| 5795 | |
| 5796 | stmt = select(user_table).join( |
| 5797 | address_table, user_table.c.id == address_table.c.user_id |
| 5798 | ) |
| 5799 | |
| 5800 | The above statement generates SQL similar to: |
| 5801 | |
| 5802 | .. sourcecode:: sql |
| 5803 | |
| 5804 | SELECT user.id, user.name |
| 5805 | FROM user |
| 5806 | JOIN address ON user.id = address.user_id |
| 5807 | |
| 5808 | .. versionchanged:: 1.4 :meth:`_expression.Select.join` now creates |
| 5809 | a :class:`_sql.Join` object between a :class:`_sql.FromClause` |
| 5810 | source that is within the FROM clause of the existing SELECT, |
| 5811 | and a given target :class:`_sql.FromClause`, and then adds |
| 5812 | this :class:`_sql.Join` to the FROM clause of the newly generated |
| 5813 | SELECT statement. This is completely reworked from the behavior |
| 5814 | in 1.3, which would instead create a subquery of the entire |
| 5815 | :class:`_expression.Select` and then join that subquery to the |
| 5816 | target. |
| 5817 | |
| 5818 | This is a **backwards incompatible change** as the previous behavior |
| 5819 | was mostly useless, producing an unnamed subquery rejected by |
| 5820 | most databases in any case. The new behavior is modeled after |
| 5821 | that of the very successful :meth:`_orm.Query.join` method in the |
| 5822 | ORM, in order to support the functionality of :class:`_orm.Query` |
| 5823 | being available by using a :class:`_sql.Select` object with an |
| 5824 | :class:`_orm.Session`. |
| 5825 | |
| 5826 | See the notes for this change at :ref:`change_select_join`. |
| 5827 | |
| 5828 | |
| 5829 | :param target: target table to join towards |
| 5830 | |
| 5831 | :param onclause: ON clause of the join. If omitted, an ON clause |
| 5832 | is generated automatically based on the :class:`_schema.ForeignKey` |
| 5833 | linkages between the two tables, if one can be unambiguously |
| 5834 | determined, otherwise an error is raised. |
| 5835 | |
| 5836 | :param isouter: if True, generate LEFT OUTER join. Same as |
| 5837 | :meth:`_expression.Select.outerjoin`. |
| 5838 |
no outgoing calls
no test coverage detected