summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorSarah Boyce <42296566+sarahboyce@users.noreply.github.com>2023-10-25 17:30:32 +0200
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2023-10-30 12:04:55 +0100
commite4d012ca05b23445f422b0400d6dd7aa85743885 (patch)
treeaae4a65b182cfb1c2b482ce0df918479791708f2 /docs
parent34b411762b50883d768d7b67e0a158ec39da8b09 (diff)
Refs #29850 -- Added exclusion support to window frames.
Diffstat (limited to 'docs')
-rw-r--r--docs/ref/models/expressions.txt34
-rw-r--r--docs/releases/5.1.txt5
2 files changed, 37 insertions, 2 deletions
diff --git a/docs/ref/models/expressions.txt b/docs/ref/models/expressions.txt
index 6dfe6c453a..807a946551 100644
--- a/docs/ref/models/expressions.txt
+++ b/docs/ref/models/expressions.txt
@@ -889,7 +889,7 @@ Frames
For a window frame, you can choose either a range-based sequence of rows or an
ordinary sequence of rows.
-.. class:: ValueRange(start=None, end=None)
+.. class:: ValueRange(start=None, end=None, exclusion=None)
.. attribute:: frame_type
@@ -899,18 +899,48 @@ ordinary sequence of rows.
the standard start and end points, such as ``CURRENT ROW`` and ``UNBOUNDED
FOLLOWING``.
-.. class:: RowRange(start=None, end=None)
+ .. versionchanged:: 5.1
+
+ The ``exclusion`` argument was added.
+
+.. class:: RowRange(start=None, end=None, exclusion=None)
.. attribute:: frame_type
This attribute is set to ``'ROWS'``.
+ .. versionchanged:: 5.1
+
+ The ``exclusion`` argument was added.
+
Both classes return SQL with the template:
.. code-block:: sql
%(frame_type)s BETWEEN %(start)s AND %(end)s
+.. class:: WindowFrameExclusion
+
+ .. versionadded:: 5.1
+
+ .. attribute:: CURRENT_ROW
+
+ .. attribute:: GROUP
+
+ .. attribute:: TIES
+
+ .. attribute:: NO_OTHERS
+
+The ``exclusion`` argument allows excluding rows
+(:attr:`~WindowFrameExclusion.CURRENT_ROW`), groups
+(:attr:`~WindowFrameExclusion.GROUP`), and ties
+(:attr:`~WindowFrameExclusion.TIES`) from the window frames on supported
+databases:
+
+.. code-block:: sql
+
+ %(frame_type)s BETWEEN %(start)s AND %(end)s EXCLUDE %(exclusion)s
+
Frames narrow the rows that are used for computing the result. They shift from
some start point to some specified end point. Frames can be used with and
without partitions, but it's often a good idea to specify an ordering of the
diff --git a/docs/releases/5.1.txt b/docs/releases/5.1.txt
index 42fb17d003..73343b7499 100644
--- a/docs/releases/5.1.txt
+++ b/docs/releases/5.1.txt
@@ -174,6 +174,11 @@ Models
* :class:`~django.db.models.expressions.RowRange` now accepts positive integers
for the ``start`` argument and negative integers for the ``end`` argument.
+* The new ``exclusion`` argument of
+ :class:`~django.db.models.expressions.RowRange` and
+ :class:`~django.db.models.expressions.ValueRange` allows excluding rows,
+ groups, and ties from the window frames.
+
Requests and Responses
~~~~~~~~~~~~~~~~~~~~~~