summaryrefslogtreecommitdiff
path: root/tests/ordering
AgeCommit message (Collapse)Author
2026-02-13Fixed #36857 -- Added QuerySet.totally_ordered property.VIZZARD-X
Thanks Simon Charette for the idea.
2026-02-03Refs CVE-2026-1312 -- Raised ValueError when FilteredRelation aliases ↵Jacob Walls
contain periods. This prevents failures at the database layer, given that aliases in the ON clause are not quoted. Systematically quoting aliases even in FilteredRelation is tracked in https://code.djangoproject.com/ticket/36795.
2026-02-03Fixed CVE-2026-1312 -- Protected order_by() from SQL injection via aliases ↵Jacob Walls
with periods. Before, `order_by()` treated a period in a field name as a sign that it was requested via `.extra(order_by=...)` and thus should be passed through as raw table and column names, even if `extra()` was not used. Since periods are permitted in aliases, this meant user-controlled aliases could force the `order_by()` clause to resolve to a raw table and column pair instead of the actual target field for the alias. In practice, only `FilteredRelation` was affected, as the other expressions we tested, e.g. `F`, aggressively optimize away the ordering expressions into ordinal positions, e.g. ORDER BY 2, instead of ORDER BY "table".column. Thanks Solomon Kebede for the report, and Simon Charette and Jake Howard for reviews.
2025-06-05Fixed #36407 -- Ensured default value is cast in Case expressions used in ↵ontowhee
ORDER BY clause. Thanks to deceze for the report. Thanks to Sarah Boyce for the test. Thanks to Simon Charette for the investigation and review.
2023-02-27Fixed #34372 -- Fixed queryset crash on order by aggregation using OrderBy.Simon Charette
Regression in 278881e37619278789942513916acafaa88d26f3 caused by a lack of expression copying when an OrderBy expression is explicitly provided. Thanks Jannis Vajen for the report and regression test.
2023-02-20Fixed #34346 -- Ordered selected expressions by position.Simon Charette
Used the same approach as for #34176 by using selected expressions position to prevent ambiguous aliases in collisions. Thanks henribru for the report. Regression in 04518e310d4552ff7595a34f5a7f93487d78a406.
2023-02-18Refs #33308 -- Added tests for queryset ordered by annotation with ↵Simon Charette
nulls_first/nulls_last.
2022-10-18Fixed #34105 -- Fixed crash of ordering by nested selected expression.Simon Charette
This stops ordering by nested selected references. It's not supported on PostgreSQL and not required to support psycopg3. Regression in 04518e310d4552ff7595a34f5a7f93487d78a406. Thanks Matt Westcott for the report.
2022-10-08Refs #33990 -- Renamed TransactionTestCase.assertQuerysetEqual() to ↵Gregor Gärtner
assertQuerySetEqual(). Co-Authored-By: Michael Howitz <mh@gocept.com>
2022-10-04Fixed #34012 -- Made QuerySet.order_by() apply transforms on related fields ↵David Sanders
for models with Meta.ordering. This makes QuerySet.order_by() no longer ignore trailing transforms for models with Meta.ordering. As a consequence, FieldError is raised in such cases for non-existent fields. Thanks to Klaas van Schelven for the report and Mariusz Felisiak for the review and advice.
2022-05-12Fixed #29538 -- Fixed crash of ordering by related fields when Meta.ordering ↵Ed Rivas
contains expressions. Thanks Simon Charette for the review.
2022-02-22Removed redundant QuerySet.all() calls in docs and tests.Nick Pope
Most QuerySet methods are mapped onto the Manager and, in general, it isn't necessary to call .all() on the manager.
2022-02-07Refs #33476 -- Reformatted code with Black.django-bot
2021-03-16Fixed #32546 -- Avoided Meta.ordering columns in GROUP BY clauses.Yuri Konotopov
Follow up to 0ddb4ebf7bfcc4730c80a772dd146a49ef6895f6.
2020-11-03Removed serial pk assumption in ordering tests.Tim Graham
Fixed OrderingTests.test_order_by_fk_attname and test_order_by_pk on CockroachDB.
2020-07-15Fixed #30446 -- Resolved Value.output_field for stdlib types.Simon Charette
This required implementing a limited form of dynamic dispatch to combine expressions with numerical output. Refs #26355 should eventually provide a better interface for that.
2020-06-10Fixed #31657 -- Fixed ordering by attnames of self-referential ForeignKeys.Hasan Ramezani
2020-06-10Refs #31657 -- Added test for ordering by self-referential ForeignKeys.Hasan Ramezani
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
2019-09-10Refs #14357 -- Made Meta.ordering not affect GROUP BY queries.Mariusz Felisiak
Per deprecation timeline.
2019-07-11Refs #30557 -- Fixed crash of ordering by ptr fields when Meta.ordering ↵Mariusz Felisiak
contains F() expressions. Thanks Can Sarıgöl for the report. Follow up to 8c5f9906c56ac72fc4f13218dd90bdf9bc8a248b.
2019-07-11Fixed #30557 -- Fixed crash of ordering by ptr fields when Meta.ordering ↵Hasan Ramezani
contains expressions.
2019-05-31Fixed #26192 -- Fixed crash of ordering by constants on PostgreSQL.Mariusz Felisiak
Thanks Simon Charette for the review.
2019-05-31Refs #26192 -- Added tests for ordering by constant value.Mariusz Felisiak
2019-05-23Fixed #30501 -- Preventing QuerySet.reverse() from mutating expressions in ↵Mariusz Felisiak
QuerySet.order_by and Meta.ordering.
2019-05-18Fixed #30463 -- Fixed crash of deprecation message when Meta.ordering ↵ruchit2801
contains expressions. Regression in 1b1f64ee5a78cc217fead52cbae23114502cf564.
2018-09-13Refs #14357 -- Deprecated Meta.ordering affecting GROUP BY queries.Ramiro Morales
Thanks Ramiro Morales for contributing to the patch.
2017-11-27Fixed #28848 -- Fixed SQLite/MySQL crash when ordering by a filtered ↵Raphael Michel
subquery that uses nulls_first/nulls_last.
2017-10-21Fixed #28722 -- Made QuerySet.reverse() affect nulls_first/nulls_last.Tomer Chachamu
2017-09-05Fixed #28335 -- Allowed query expressions in Meta.ordering.Dima Kudosh
2017-05-31Fixed #22550 -- Prohibited QuerySet.last()/reverse() after slicing.Matthias Erll
2017-01-18Refs #23919 -- Removed python_2_unicode_compatible decorator usageClaude Paroz
2017-01-18Refs #23919 -- Removed encoding preambles and future importsClaude Paroz
2016-12-08Fixed #13312 -- Allowed specifying the order of null fields in queries.Yohann Gabory
Thanks Mariusz Felisiak for finishing the patch.
2016-11-15Used setUpTestData() in ordering tests.Mariusz Felisiak
2016-11-10Refs #27392 -- Removed "Tests that", "Ensures that", etc. from test docstrings.za
2016-09-13Fixed #27203 -- Replaced assertQuerysetEqual(..., lambda o: o) with ↵Mads Jensen
assertSequenceEqual().
2016-09-09Refs #25415 -- Fixed invalid models in the test suite.Adam Chainz
2016-03-09Correct a grammatical error: "it's related model"Noenglish Professorbut
I am no English professor, but "inheriting its related model" should not contain an apostrophe. For reference, see http://theoatmeal.com/comics/apostrophe
2015-07-27Fixed #21127 -- Started deprecation toward requiring on_delete for ↵Flavio Curella
ForeignKey/OneToOneField
2015-04-20Fixed #24654 -- Based ordering circular references detection on columns.Simon Charette
Thanks to Elmar Bucher for the report and Tim for the review.
2015-01-28Refs #24060 -- Added a test demonstrating reverse order isn't mutableJosh Smeaton
2015-01-19Fixed #24174 -- Fixed extra order by descendingJosh Smeaton
2015-01-13Fixed #24060 -- Added OrderBy ExpressionsJosh Smeaton
2014-09-24Removed numbering from the models.py header of some test packages.Loic Bistuer
This is a reliqua from the early days of the modeltests/regressiontests era.
2014-04-30Fixed #19195 -- Allow explicit ordering by a relation `_id` field.Simon Charette
Thanks to chrisedgemon for the report and shaib, akaariai and timgraham for the review.
2013-11-02Fixing E302 ErrorsJason Myers
Signed-off-by: Jason Myers <jason@jasonamyers.com>
2013-10-23Fixed #21298 -- Fixed E301 pep8 warningsAlasdair Nicol
2013-10-19Removed unused local variables in tests.Tim Graham