summaryrefslogtreecommitdiff
path: root/doc/build/tutorial
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2022-07-27 11:36:57 -0400
committerFederico Caselli <cfederico87@gmail.com>2022-08-01 21:46:33 +0000
commit1ecbf14cc24aa0b1d303926178941c1f7f9fe93b (patch)
tree9d6db71363b3dd90dfc69b5388902d68f9e57cb2 /doc/build/tutorial
parent3ff18812d8d80b2016ceeea98c808a76cae85e48 (diff)
downloadsqlalchemy-1ecbf14cc24aa0b1d303926178941c1f7f9fe93b.tar.gz
implement tuple-slices from .c collections
Added new syntax to the ``.c`` collection on all :class:`.FromClause` objects allowing tuples of keys to be passed to ``__getitem__()``, along with support for ``select()`` handling of ``.c`` collections directly, allowing the syntax ``select(table.c['a', 'b', 'c'])`` to be possible. The sub-collection returned is itself a :class:`.ColumnCollection` which is also directly consumable by :func:`_sql.select` and similar now. Fixes: #8285 Change-Id: I2236662c477ffc50af079310589e213323c960d1
Diffstat (limited to 'doc/build/tutorial')
-rw-r--r--doc/build/tutorial/data_select.rst13
1 files changed, 13 insertions, 0 deletions
diff --git a/doc/build/tutorial/data_select.rst b/doc/build/tutorial/data_select.rst
index 6d52b4627..b55113fd3 100644
--- a/doc/build/tutorial/data_select.rst
+++ b/doc/build/tutorial/data_select.rst
@@ -95,6 +95,7 @@ elements within each row:
The following sections will discuss the SELECT construct in more detail.
+.. _tutorial_selecting_columns:
Setting the COLUMNS and FROM clause
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -120,6 +121,18 @@ are represented by those columns::
{opensql}SELECT user_account.name, user_account.fullname
FROM user_account
+Alternatively, when using the :attr:`.FromClause.c` collection of any
+:class:`.FromClause` such as :class:`.Table`, multiple columns may be specified
+for a :func:`_sql.select` by using a tuple of string names::
+
+ >>> print(select(user_table.c['name', 'fullname']))
+ {opensql}SELECT user_account.name, user_account.fullname
+ FROM user_account
+
+.. versionadded:: 2.0 Added tuple-accessor capability to the
+ :attr`.FromClause.c` collection
+
+
.. _tutorial_selecting_orm_entities:
Selecting ORM Entities and Columns