summaryrefslogtreecommitdiff
path: root/doc/build/tutorial
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2021-04-23 19:15:48 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2021-04-23 19:15:48 -0400
commit1443945e61f1f113e46a5044315a91558d4d232a (patch)
tree228f8909810351785f42dafb91b5870ef016a078 /doc/build/tutorial
parentc4fb058cae423e04e7131005c55c8826abda68e2 (diff)
downloadsqlalchemy-1443945e61f1f113e46a5044315a91558d4d232a.tar.gz
Add order by to union example
the query in the second union example needs order by to produce determinstic results on all plaforms including OSX, arm Change-Id: I88fcc391561db8567c389ed9e904e5de29c1c2ad
Diffstat (limited to 'doc/build/tutorial')
-rw-r--r--doc/build/tutorial/data_select.rst9
1 files changed, 7 insertions, 2 deletions
diff --git a/doc/build/tutorial/data_select.rst b/doc/build/tutorial/data_select.rst
index 39ea937aa..73261500e 100644
--- a/doc/build/tutorial/data_select.rst
+++ b/doc/build/tutorial/data_select.rst
@@ -1077,7 +1077,11 @@ it provides a :meth:`_sql.SelectBase.subquery` method which will produce a
collection that may be referred towards in an enclosing :func:`_sql.select`::
>>> u_subq = u.subquery()
- >>> stmt = select(u_subq.c.name, address_table.c.email_address).join_from(address_table, u_subq)
+ >>> stmt = (
+ ... select(u_subq.c.name, address_table.c.email_address).
+ ... join_from(address_table, u_subq).
+ ... order_by(u_subq.c.name, address_table.c.email_address)
+ ... )
>>> with engine.connect() as conn:
... result = conn.execute(stmt)
... print(result.all())
@@ -1092,8 +1096,9 @@ collection that may be referred towards in an enclosing :func:`_sql.select`::
FROM user_account
WHERE user_account.name = ?)
AS anon_1 ON anon_1.id = address.user_id
+ ORDER BY anon_1.name, address.email_address
[generated in ...] ('sandy', 'spongebob')
- {stop}[('spongebob', 'spongebob@sqlalchemy.org'), ('sandy', 'sandy@sqlalchemy.org'), ('sandy', 'sandy@squirrelpower.org')]
+ {stop}[('sandy', 'sandy@sqlalchemy.org'), ('sandy', 'sandy@squirrelpower.org'), ('spongebob', 'spongebob@sqlalchemy.org')]
{opensql}ROLLBACK{stop}