r"""Produce an inner join between left and right clauses. :func:`.orm.join` is an extension to the core join interface provided by :func:`.sql.expression.join()`, where the left and right selectables may be not only core selectable objects such as :class:`.Table`, but also mapped cl
(
left, right, onclause=None, isouter=False,
full=False, join_to_left=None)
| 895 | |
| 896 | |
| 897 | def join( |
| 898 | left, right, onclause=None, isouter=False, |
| 899 | full=False, join_to_left=None): |
| 900 | r"""Produce an inner join between left and right clauses. |
| 901 | |
| 902 | :func:`.orm.join` is an extension to the core join interface |
| 903 | provided by :func:`.sql.expression.join()`, where the |
| 904 | left and right selectables may be not only core selectable |
| 905 | objects such as :class:`.Table`, but also mapped classes or |
| 906 | :class:`.AliasedClass` instances. The "on" clause can |
| 907 | be a SQL expression, or an attribute or string name |
| 908 | referencing a configured :func:`.relationship`. |
| 909 | |
| 910 | :func:`.orm.join` is not commonly needed in modern usage, |
| 911 | as its functionality is encapsulated within that of the |
| 912 | :meth:`.Query.join` method, which features a |
| 913 | significant amount of automation beyond :func:`.orm.join` |
| 914 | by itself. Explicit usage of :func:`.orm.join` |
| 915 | with :class:`.Query` involves usage of the |
| 916 | :meth:`.Query.select_from` method, as in:: |
| 917 | |
| 918 | from sqlalchemy.orm import join |
| 919 | session.query(User).\ |
| 920 | select_from(join(User, Address, User.addresses)).\ |
| 921 | filter(Address.email_address=='foo@bar.com') |
| 922 | |
| 923 | In modern SQLAlchemy the above join can be written more |
| 924 | succinctly as:: |
| 925 | |
| 926 | session.query(User).\ |
| 927 | join(User.addresses).\ |
| 928 | filter(Address.email_address=='foo@bar.com') |
| 929 | |
| 930 | See :meth:`.Query.join` for information on modern usage |
| 931 | of ORM level joins. |
| 932 | |
| 933 | .. versionchanged:: 0.8.1 - the ``join_to_left`` parameter |
| 934 | is no longer used, and is deprecated. |
| 935 | |
| 936 | """ |
| 937 | return _ORMJoin(left, right, onclause, isouter, full) |
| 938 | |
| 939 | |
| 940 | def outerjoin(left, right, onclause=None, full=False, join_to_left=None): |
no test coverage detected