summaryrefslogtreecommitdiff
path: root/tests/expressions_window
AgeCommit message (Collapse)Author
2025-07-23Refs #36500 -- Rewrapped long docstrings and block comments via a script.django-bot
Rewrapped long docstrings and block comments to 79 characters + newline using script from https://github.com/medmunds/autofix-w505.
2025-03-03Fixed #35444 -- Added generic support for Aggregate.order_by.Chris Muthig
This moves the behaviors of `order_by` used in Postgres aggregates into the `Aggregate` class. This allows for creating aggregate functions that support this behavior across all database engines. This is shown by moving the `StringAgg` class into the shared `aggregates` module and adding support for all databases. The Postgres `StringAgg` class is now a thin wrapper on the new shared `StringAgg` class. Thank you Simon Charette for the review.
2024-08-13Fixed #35665 -- Fixed a crash when passing an empty order_by to Window.Simon Charette
This also caused un-ordered sliced prefetches to crash as they rely on Window. Regression in e16d0c176e9b89628cdec5e58c418378c4a2436a that made OrderByList piggy-back ExpressionList without porting the empty handling that the latter provided. Supporting explicit empty ordering on Window functions and slicing is arguably a foot-gun design due to how backends will return undeterministic results but this is a problem that requires a larger discussion. Refs #35064. Thanks Andrew Backer for the report and Mariusz for the review.
2023-12-29Fixed #35064 -- Fixed Window(order_by) crash with DecimalFields on SQLite.Simon Charette
This avoids cast of Window(order_by) for DecimalFields on SQLite. This was achieved by piggy-backing ExpressionList which already implements a specialized as_sqlite() method to override the inherited behaviour of Func through SQLiteNumericMixin. Refs #31723. Thanks Quoates for the report.
2023-11-23Fixed #34987 -- Fixed queryset crash when mixing aggregate and window ↵Simon Charette
annotations. Regression in f387d024fc75569d2a4a338bfda76cc2f328f627. Just like `OrderByList` the `ExpressionList` expression used to wrap `Window.partition_by` must implement `get_group_by_cols` to ensure the necessary grouping when mixing window expressions with aggregate annotations is performed against the partition members and not the partition expression itself. This is necessary because while `partition_by` is implemented as a source expression of `Window` it's actually a fragment of the WINDOW expression at the SQL level and thus it should result in a group by its members and not the sum of them. Thanks ElRoberto538 for the report.
2023-10-30Refs #29850 -- Added exclusion support to window frames.Sarah Boyce
2023-10-28Refs #29850 -- Added RowRange support for positive integer start and ↵Sarah Boyce
negative integer end.
2023-02-27Fixed #34368 -- Made subquery raise NotSupportedError when referencing outer ↵Simon Charette
window expression. Regression in f387d024fc75569d2a4a338bfda76cc2f328f627. Co-authored-by: Jannis Vajen <jvajen@gmail.com>
2022-11-11Refs #28477 -- Reduced complexity of aggregation over qualify queries.Simon Charette
2022-10-08Refs #33990 -- Renamed TransactionTestCase.assertQuerysetEqual() to ↵Gregor Gärtner
assertQuerySetEqual(). Co-Authored-By: Michael Howitz <mh@gocept.com>
2022-08-29Refs #28333 -- Fixed NonQueryWindowTests.test_invalid_filter() on databases ↵Mariusz Felisiak
that don't support window expressions.
2022-08-15Refs #28333 -- Added partial support for filtering against window functions.Simon Charette
Adds support for joint predicates against window annotations through subquery wrapping while maintaining errors for disjointed filter attempts. The "qualify" wording was used to refer to predicates against window annotations as it's the name of a specialized Snowflake extension to SQL that is to window functions what HAVING is to aggregates. While not complete the implementation should cover most of the common use cases for filtering against window functions without requiring the complex subquery pushdown and predicate re-aliasing machinery to deal with disjointed predicates against columns, aggregates, and window functions. A complete disjointed filtering implementation should likely be deferred until proper QUALIFY support lands or the ORM gains a proper subquery pushdown interface.
2022-02-07Refs #33476 -- Refactored code to strictly match 88 characters line length.Mariusz Felisiak
2022-02-07Refs #33476 -- Reformatted code with Black.django-bot
2021-11-23Fixed #33304 -- Allowed passing string expressions to Window(order_by).Simon Charette
2020-12-10Fixed #32178 -- Allowed database backends to skip tests and mark expected ↵Hasan Ramezani
failures. Co-authored-by: Tim Graham <timograham@gmail.com>
2020-11-27Fixed #25534, Fixed #31639 -- Added support for transform references in ↵Ian Foote
expressions. Thanks Mariusz Felisiak and Simon Charette for reviews.
2020-10-14Refs #32096 -- Added test for window expressions with JSONField key transforms.Mariusz Felisiak
2020-09-23Fixed #31723 -- Fixed window functions crash with DecimalField on SQLite.Hasan Ramezani
Thanks Simon Charette for the initial patch.
2020-04-30Removed unused __str__() methods in tests models.Mariusz Felisiak
Follow up to 6461583b6cc257d25880ef9a9fd7e2125ac53ce1.
2020-02-04Simplified imports from django.db and django.contrib.gis.db.Nick Pope
2020-01-21Refs #29095 -- Added test for using QuerySet.count() with window expressions ↵Christopher G Johnson
ordered by related fields. Fixed in 3f32154f40a855afa063095e3d091ce6be21f2c5.
2020-01-20Fixed #31183 -- Added a feature flag for "<db> only supports UNBOUNDED ↵Tim Graham
together with PRECEDING and FOLLOWING".
2019-12-06Fixed #31060 -- Reallowed window expressions to be used in conditions ↵Alex Aktsipetrov
outside of queryset filters. Regression in 4edad1ddf6203326e0be4bdb105beecb0fe454c4. Thanks utapyngo for the report.
2019-11-18Relaxed some query ordering assertions in tests.Tim Graham
It accounts for differences seen on cockroachdb.
2019-08-02Fixed #30668 -- Made QuerySet.filter() raise NotSupportedError if any of ↵aaktsipetrov
source expressions is not filterable.
2019-05-03Fixed NonQueryWindowTests.test_unsupported_backend() on MySQL.Mariusz Felisiak
2019-02-14Fixed #29619 -- Added field names to some FieldErrors.Hasan Ramezani
2019-02-09Refs #26608 -- Added a database feature for fixed frame range distance support.Simon Charette
2019-02-09Fixed #30027 -- Errored out on Window function usage if unsupported.Simon Charette
2019-02-09Refs #30027 -- Enabled window function tests on SQLite 3.25+.Simon Charette
2019-01-03Refs #29851 -- Fixed test_subquery_row_range_rank() crash on MariaDB 10.2+.Mariusz Felisiak
Thanks Tom Forbes for the report.
2018-12-27Fixed #29851 -- Fixed crash of annotations with window expressions in Subquery.Mariusz Felisiak
2018-10-21Fixed #29847 -- Ensured proper ordering in queries.Florian Apolloner
Even though good databases tend to keep the result sorted by the/one window expression and the planners are smart enough to not resort if not required, it is not valid to rely on this. MariaDB specifically did return whatever order it wanted, which is completely okay. Now we sort towards the expected data for all databases.
2018-07-30Refs #29548 -- Fixed failing window tests on MariaDB 10.3.Tom Forbes
2018-03-01Fixed #29172 -- Fixed crash with Window expression in a subquery.Tomáš Ehrlich
2017-09-18Fixed #26608 -- Added support for window expressions (OVER clause).Mads Jensen
Thanks Josh Smeaton, Mariusz Felisiak, Sergey Fedoseev, Simon Charettes, Adam Chainz/Johnson and Tim Graham for comments and reviews and Jamie Cockburn for initial patch.