]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
update ORM join doc
authorMike Bayer <mike_mp@zzzcomputing.com>
Tue, 19 Apr 2022 03:12:31 +0000 (23:12 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Tue, 19 Apr 2022 03:15:58 +0000 (23:15 -0400)
forgot to remove string support for the ON clause here.
will backport a deprecation message to 1.4.

Change-Id: If90e2bff929cce4dc8a6e9bd3ad818b8f8e514a6
(cherry picked from commit 13a8552053c21a9fa7ff6f992ed49ee92cca73e4)

lib/sqlalchemy/orm/util.py

index 50ac8917d3d4b51bb0022ddea3733cbd58ec0321..7f72c1fc086651c9330b7317c95627fc37b49e49 100644 (file)
@@ -1809,30 +1809,35 @@ def join(
     left and right selectables may be not only core selectable
     objects such as :class:`_schema.Table`, but also mapped classes or
     :class:`.AliasedClass` instances.   The "on" clause can
-    be a SQL expression, or an attribute or string name
+    be a SQL expression or an ORM mapped attribute
     referencing a configured :func:`_orm.relationship`.
 
+    .. deprecated:: 1.4 using a string relationship name for the "onclause"
+       is deprecated and will be removed in 2.0; the onclause may be only
+       an ORM-mapped relationship attribute or a SQL expression construct.
+
     :func:`_orm.join` is not commonly needed in modern usage,
     as its functionality is encapsulated within that of the
-    :meth:`_query.Query.join` method, which features a
+    :meth:`_sql.Select.join` and :meth:`_query.Query.join`
+    methods. which feature a
     significant amount of automation beyond :func:`_orm.join`
-    by itself.  Explicit usage of :func:`_orm.join`
-    with :class:`_query.Query` involves usage of the
-    :meth:`_query.Query.select_from` method, as in::
+    by itself.  Explicit use of :func:`_orm.join`
+    with ORM-enabled SELECT statements involves use of the
+    :meth:`_sql.Select.select_from` method, as in::
 
         from sqlalchemy.orm import join
-        session.query(User).\
+        stmt = select(User).\
             select_from(join(User, Address, User.addresses)).\
             filter(Address.email_address=='foo@bar.com')
 
     In modern SQLAlchemy the above join can be written more
     succinctly as::
 
-        session.query(User).\
+        stmt = select(User).\
                 join(User.addresses).\
                 filter(Address.email_address=='foo@bar.com')
 
-    See :meth:`_query.Query.join` for information on modern usage
+    See :ref:`orm_queryguide_joins` for information on modern usage
     of ORM level joins.
 
     .. deprecated:: 0.8