Commit Graph

47 Commits

Author SHA1 Message Date
Simon Charette 278881e376 Fixed #34346 -- Ordered selected expressions by position.
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 04518e310d.
2023-02-20 05:54:25 +01:00
Simon Charette a6511bc233 Refs #33308 -- Added tests for queryset ordered by annotation with nulls_first/nulls_last. 2023-02-18 16:28:10 +01:00
Simon Charette d62563cbb1
Fixed #34105 -- Fixed crash of ordering by nested selected expression.
This stops ordering by nested selected references. It's not supported on
PostgreSQL and not required to support psycopg3.

Regression in 04518e310d.

Thanks Matt Westcott for the report.
2022-10-18 17:31:45 -07:00
Gregor Gärtner f0c06f8ab7 Refs #33990 -- Renamed TransactionTestCase.assertQuerysetEqual() to assertQuerySetEqual().
Co-Authored-By: Michael Howitz <mh@gocept.com>
2022-10-08 08:07:38 +02:00
David Sanders 4771a1694b Fixed #34012 -- Made QuerySet.order_by() apply transforms on related fields 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-10-04 08:19:34 +02:00
Ed Rivas 2798c937de Fixed #29538 -- Fixed crash of ordering by related fields when Meta.ordering contains expressions.
Thanks Simon Charette for the review.
2022-05-12 07:19:16 +02:00
Nick Pope 847f46e9bf
Removed redundant QuerySet.all() calls in docs and tests.
Most QuerySet methods are mapped onto the Manager and, in general,
it isn't necessary to call .all() on the manager.
2022-02-22 10:29:38 +01:00
django-bot 9c19aff7c7 Refs #33476 -- Reformatted code with Black. 2022-02-07 20:37:05 +01:00
Yuri Konotopov 330bc402a8 Fixed #32546 -- Avoided Meta.ordering columns in GROUP BY clauses.
Follow up to 0ddb4ebf7b.
2021-03-16 07:58:38 +01:00
Tim Graham be27da9d6e Removed serial pk assumption in ordering tests.
Fixed OrderingTests.test_order_by_fk_attname and test_order_by_pk on
CockroachDB.
2020-11-03 22:26:18 -05:00
Simon Charette 1e38f1191d Fixed #30446 -- Resolved Value.output_field for stdlib types.
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-07-15 10:58:29 +02:00
Hasan Ramezani 037a624120 Fixed #31657 -- Fixed ordering by attnames of self-referential ForeignKeys. 2020-06-10 11:14:26 +02:00
Hasan Ramezani c1f7de8acc Refs #31657 -- Added test for ordering by self-referential ForeignKeys. 2020-06-10 11:11:20 +02:00
Mariusz Felisiak 555e3a848e
Removed unused __str__() methods in tests models.
Follow up to 6461583b6c.
2020-04-30 09:13:23 +02:00
Nick Pope 335c9c94ac Simplified imports from django.db and django.contrib.gis.db. 2020-02-04 13:20:06 +01:00
Mariusz Felisiak 0ddb4ebf7b Refs #14357 -- Made Meta.ordering not affect GROUP BY queries.
Per deprecation timeline.
2019-09-10 12:01:00 +02:00
Mariusz Felisiak 7a42cfcfdc
Refs #30557 -- Fixed crash of ordering by ptr fields when Meta.ordering contains F() expressions.
Thanks Can Sarıgöl for the report.

Follow up to 8c5f9906c5.
2019-07-11 13:40:36 +02:00
Hasan Ramezani 8c5f9906c5 Fixed #30557 -- Fixed crash of ordering by ptr fields when Meta.ordering contains expressions. 2019-07-11 11:24:59 +02:00
Mariusz Felisiak f6075fb333 Fixed #26192 -- Fixed crash of ordering by constants on PostgreSQL.
Thanks Simon Charette for the review.
2019-05-31 07:38:48 +02:00
Mariusz Felisiak cc80979f01 Refs #26192 -- Added tests for ordering by constant value. 2019-05-31 07:38:48 +02:00
Mariusz Felisiak f8b8b00f01
Fixed #30501 -- Preventing QuerySet.reverse() from mutating expressions in QuerySet.order_by and Meta.ordering. 2019-05-23 20:33:37 +02:00
ruchit2801 04042b2b44 Fixed #30463 -- Fixed crash of deprecation message when Meta.ordering contains expressions.
Regression in 1b1f64ee5a.
2019-05-18 19:29:00 +02:00
Ramiro Morales 1b1f64ee5a Refs #14357 -- Deprecated Meta.ordering affecting GROUP BY queries.
Thanks Ramiro Morales for contributing to the patch.
2018-09-13 12:29:48 -04:00
Raphael Michel 616f468760 Fixed #28848 -- Fixed SQLite/MySQL crash when ordering by a filtered subquery that uses nulls_first/nulls_last. 2017-11-27 11:35:44 -05:00
Tomer Chachamu 21a3a29dc9 Fixed #28722 -- Made QuerySet.reverse() affect nulls_first/nulls_last. 2017-10-21 20:55:45 -04:00
Dima Kudosh 093fd479d6 Fixed #28335 -- Allowed query expressions in Meta.ordering. 2017-09-05 19:10:20 -04:00
Matthias Erll eee34ef64c Fixed #22550 -- Prohibited QuerySet.last()/reverse() after slicing. 2017-05-31 19:34:56 -04:00
Claude Paroz f3c43ad1fd Refs #23919 -- Removed python_2_unicode_compatible decorator usage 2017-01-18 13:44:34 +01:00
Claude Paroz d7b9aaa366 Refs #23919 -- Removed encoding preambles and future imports 2017-01-18 09:55:19 +01:00
Yohann Gabory 47ef8f31f3 Fixed #13312 -- Allowed specifying the order of null fields in queries.
Thanks Mariusz Felisiak for finishing the patch.
2016-12-08 09:54:07 -05:00
Mariusz Felisiak 789a02b31e Used setUpTestData() in ordering tests. 2016-11-15 08:20:22 -05:00
za 321e94fa41 Refs #27392 -- Removed "Tests that", "Ensures that", etc. from test docstrings. 2016-11-10 21:30:21 -05:00
Mads Jensen 0c1f71635f Fixed #27203 -- Replaced assertQuerysetEqual(..., lambda o: o) with assertSequenceEqual(). 2016-09-13 10:07:37 -04:00
Adam Chainz 652bcc6f5f Refs #25415 -- Fixed invalid models in the test suite. 2016-09-09 17:16:42 -04:00
Noenglish Professorbut ddf4af885f Correct a grammatical error: "it's related model"
I am no English professor, but "inheriting its related model" should not contain an apostrophe.

For reference, see http://theoatmeal.com/comics/apostrophe
2016-03-09 20:40:17 -08:00
Flavio Curella c2e70f0265 Fixed #21127 -- Started deprecation toward requiring on_delete for ForeignKey/OneToOneField 2015-07-27 18:28:13 -04:00
Simon Charette b44ed404c7 Fixed #24654 -- Based ordering circular references detection on columns.
Thanks to Elmar Bucher for the report and Tim for the review.
2015-04-20 15:49:58 -04:00
Josh Smeaton f218a2ff45 Refs #24060 -- Added a test demonstrating reverse order isn't mutable 2015-01-28 10:59:30 +11:00
Josh Smeaton 69c6a6868f Fixed #24174 -- Fixed extra order by descending 2015-01-19 12:51:27 +11:00
Josh Smeaton 21b858cb67 Fixed #24060 -- Added OrderBy Expressions 2015-01-13 09:39:55 +11:00
Loic Bistuer 2f3a4cd573 Removed numbering from the models.py header of some test packages.
This is a reliqua from the early days of the modeltests/regressiontests era.
2014-09-24 17:28:56 +07:00
Simon Charette 24ec9538b7 Fixed #19195 -- Allow explicit ordering by a relation `_id` field.
Thanks to chrisedgemon for the report and shaib, akaariai and
timgraham for the review.
2014-04-30 14:23:19 -04:00
Jason Myers c3791463a5 Fixing E302 Errors
Signed-off-by: Jason Myers <jason@jasonamyers.com>
2013-11-02 23:48:47 -05:00
Alasdair Nicol c3aa2948c6 Fixed #21298 -- Fixed E301 pep8 warnings 2013-10-23 13:45:03 +01:00
Tim Graham 96d1d4e292 Removed unused local variables in tests. 2013-10-19 08:31:38 -04:00
Claude Paroz 5c1143910e Removed most of absolute_import imports
Should be unneeded with Python 2.7 and up.
Added some unicode_literals along the way.
2013-07-29 20:28:13 +02:00
Florian Apolloner 89f40e3624 Merged regressiontests and modeltests into the test root. 2013-02-26 14:36:57 +01:00