]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
clarify "selecting individual columns" doc
authorMike Bayer <mike_mp@zzzcomputing.com>
Wed, 8 Mar 2023 22:23:31 +0000 (17:23 -0500)
committerMike Bayer <mike_mp@zzzcomputing.com>
Wed, 8 Mar 2023 22:25:02 +0000 (17:25 -0500)
Just went to refer to this and it was full of difficult terminology
for no good reason.   What's troubling is that this doc is like the
tenth time I've rewritten this and it still was loaded with too
much jargon and not clear about the behavior.

Change-Id: I22745962568277eead6081a82003ac90665048e0

doc/build/orm/queryguide/select.rst

index 7a2eb3a862ff11c4897384c85241bf3cb0842838..c14eb134e40108ef8febfaf0c9b7729687e1ff73 100644 (file)
@@ -175,11 +175,12 @@ above using this form as well::
 Selecting Individual Attributes
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
-The attributes on a mapped class, such as ``User.name`` and ``Address.email_address``,
-have a similar behavior as that of the entity class itself such as ``User``
-in that they are automatically converted into ORM-annotated Core objects
-when passed to :func:`_sql.select`.   They may be used in the same way
-as table columns are used::
+The attributes on a mapped class, such as ``User.name`` and
+``Address.email_address``, can be used just like :class:`_schema.Column` or
+other SQL expression objects when passed to :func:`_sql.select`. Creating a
+:func:`_sql.select` that is against specific columns will return :class:`.Row`
+objects, and **not** entities like ``User`` or ``Address`` objects.
+Each :class:`.Row` will have each column represented individually::
 
     >>> result = session.execute(
     ...     select(User.name, Address.email_address)
@@ -191,11 +192,8 @@ as table columns are used::
     ORDER BY user_account.id, address.id
     [...] (){stop}
 
-ORM attributes, themselves known as
-:class:`_orm.InstrumentedAttribute`
-objects, can be used in the same way as any :class:`_sql.ColumnElement`,
-and are delivered in result rows just the same way, such as below
-where we refer to their values by column name within each row::
+The above statement returns :class:`.Row` objects with ``name`` and
+``email_address`` columns, as illustrated in the runtime demonstration below::
 
     >>> for row in result:
     ...     print(f"{row.name}  {row.email_address}")