Skip to content

Commit 1443945

Browse files
committed
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
1 parent c4fb058 commit 1443945

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

doc/build/tutorial/data_select.rst

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1077,7 +1077,11 @@ it provides a :meth:`_sql.SelectBase.subquery` method which will produce a
10771077
collection that may be referred towards in an enclosing :func:`_sql.select`::
10781078

10791079
>>> u_subq = u.subquery()
1080-
>>> stmt = select(u_subq.c.name, address_table.c.email_address).join_from(address_table, u_subq)
1080+
>>> stmt = (
1081+
... select(u_subq.c.name, address_table.c.email_address).
1082+
... join_from(address_table, u_subq).
1083+
... order_by(u_subq.c.name, address_table.c.email_address)
1084+
... )
10811085
>>> with engine.connect() as conn:
10821086
... result = conn.execute(stmt)
10831087
... print(result.all())
@@ -1092,8 +1096,9 @@ collection that may be referred towards in an enclosing :func:`_sql.select`::
10921096
FROM user_account
10931097
WHERE user_account.name = ?)
10941098
AS anon_1 ON anon_1.id = address.user_id
1099+
ORDER BY anon_1.name, address.email_address
10951100
[generated in ...] ('sandy', 'spongebob')
1096-
{stop}[('spongebob', 'spongebob@sqlalchemy.org'), ('sandy', 'sandy@sqlalchemy.org'), ('sandy', 'sandy@squirrelpower.org')]
1101+
{stop}[('sandy', 'sandy@sqlalchemy.org'), ('sandy', 'sandy@squirrelpower.org'), ('spongebob', 'spongebob@sqlalchemy.org')]
10971102
{opensql}ROLLBACK{stop}
10981103

10991104

0 commit comments

Comments
 (0)