Skip to content

Commit 1484a9b

Browse files
committed
Add documentation and changelog
1 parent 7d761b8 commit 1484a9b

2 files changed

Lines changed: 27 additions & 0 deletions

File tree

CHANGELOG.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,13 @@ Changelog
88
1.1
99
===
1010

11+
1.1.7
12+
-----
13+
14+
Added
15+
^^^^^
16+
- ``QuerySet.union()`` — SQL UNION query support for combining results from multiple QuerySets, including support for union across different models, ``union(all=True)`` for duplicates, ``order_by()``, ``limit()``, and ``count()``.
17+
1118
1.1.6
1219
-----
1320

docs/query.rst

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,3 +349,23 @@ You can view full example here: :ref:`example_prefetching`
349349

350350
.. autoclass:: tortoise.query_utils.Prefetch
351351
:members:
352+
353+
.. _union:
354+
355+
Union
356+
=====
357+
358+
Tortoise ORM supports SQL ``UNION`` queries to combine results from multiple QuerySets.
359+
360+
Example usage:
361+
362+
.. code-block:: python3
363+
364+
qs1 = Tournament.filter(name__in=["T1", "T2"]).only("id", "name")
365+
qs2 = Reporter.filter(name__in=["R1", "R2"]).only("id", "name")
366+
367+
result = await qs1.union(qs2)
368+
369+
.. autoclass:: tortoise.queryset.UnionQuery
370+
:members:
371+
:inherited-members:

0 commit comments

Comments
 (0)