Commit Graph

289 Commits

Author SHA1 Message Date
Daniyal f479df7f8d Refs #32508 -- Raised Type/ValueError instead of using "assert" in django.db.models.
Co-authored-by: Mariusz Felisiak <felisiak.mariusz@gmail.com>
2021-07-15 11:43:33 +02:00
Wu Haotian aba9c2de66 Fixed #32226 -- Fixed JSON format of QuerySet.explain() on PostgreSQL. 2021-07-05 09:08:39 +02:00
Wu Haotian b3b04ad211 Refs #28574 -- Added test for XML format output to Queryset.explain(). 2021-07-05 09:01:54 +02:00
abhiabhi94 cd124295d8 Fixed #32381 -- Made QuerySet.bulk_update() return the number of objects updated.
Co-authored-by: Diego Lima <diego.lima@lais.huol.ufrn.br>
2021-06-29 06:58:46 +02:00
Simon Charette b81c7562fc Fixed #32717 -- Fixed filtering of querysets combined with the | operator.
Address a long standing bug in a Where.add optimization to discard
equal nodes that was surfaced by implementing equality for Lookup
instances in bbf141bcdc.

Thanks Shaheed Haque for the report.
2021-05-13 07:26:52 +02:00
Hasan Ramezani 8de4ca74ba Fixed #32693 -- Quoted and lowercased generated column aliases. 2021-05-04 07:36:56 +02:00
Simon Charette c8b6594305 Fixed #32632, Fixed #32657 -- Removed flawed support for Subquery deconstruction.
Subquery deconstruction support required implementing complex and
expensive equality rules for sql.Query objects for little benefit as
the latter cannot themselves be made deconstructible to their reference
to model classes.

Making Expression @deconstructible and not BaseExpression allows
interested parties to conform to the "expression" API even if they are
not deconstructible as it's only a requirement for expressions allowed
in Model fields and meta options (e.g. constraints, indexes).

Thanks Phillip Cutter for the report.

This also fixes a performance regression in bbf141bcdc.
2021-04-28 12:13:55 +02:00
Mariusz Felisiak 4f600673d7 Refs #32632 -- Added tests for returning a copy when combining Q() objects. 2021-04-28 11:31:17 +02:00
Mariusz Felisiak c3278bb71f
Used assertCountEqual() in ExcludeTests.test_exclude_subquery(). 2021-04-22 10:47:10 +02:00
Simon Charette 6d0cbe42c3 Fixed #32650 -- Fixed handling subquery aliasing on queryset combination.
This issue started manifesting itself when nesting a combined subquery
relying on exclude() since 8593e162c9 but
sql.Query.combine never properly handled subqueries outer refs in the
first place, see QuerySetBitwiseOperationTests.test_subquery_aliases()
(refs #27149).

Thanks Raffaele Salmaso for the report.
2021-04-21 09:49:15 +02:00
Iuri de Silvio 9760e262f8 Fixed #32627 -- Fixed QuerySet.values()/values_list() crash on combined querysets ordered by unannotated columns. 2021-04-12 21:11:40 +02:00
Jonathan Richards 00b0786de5 Fixed #32548 -- Fixed crash when combining Q() objects with boolean expressions. 2021-03-17 21:53:39 +01:00
Mariusz Felisiak ba9a2b7544
Refs #32508 -- Raised TypeError instead of using "assert" on unsupported operations for sliced querysets. 2021-03-10 09:16:28 +01:00
Johan Schiff d01709aae2 Fixed #24141 -- Added QuerySet.contains(). 2021-03-06 20:40:29 +01:00
starryrbs 466920f6d7 Fixed #32450 -- Fixed crash when ANDing/ORing an empty Q() with not pickleable Q().
Regression in bb0b6e5263.
2021-02-18 21:13:24 +01:00
Mariusz Felisiak 5371342ed6
Fixed #32357 -- Dropped support for PostgreSQL 9.6 and PostGIS 2.3. 2021-01-19 12:25:20 +01:00
Mariusz Felisiak 06eec31970 Refs #7098 -- Removed support for passing raw column aliases to order_by().
Per deprecation timeline.
2021-01-14 17:50:04 +01:00
Mariusz Felisiak 68e3ca13d7 Refs #30988 -- Removed InvalidQuery exception per deprecation timeline. 2021-01-14 17:50:04 +01:00
Hasan Ramezani 275dd4ebba
Fixed #32178 -- Allowed database backends to skip tests and mark expected failures.
Co-authored-by: Tim Graham <timograham@gmail.com>
2020-12-10 18:00:57 +01:00
David-Wobrock ba42569d5c Fixed #31507 -- Added QuerySet.exists() optimizations to compound queries. 2020-11-16 20:29:13 +01:00
David-Wobrock 7b42d34646 Refs #27718 -- Doc'd and tested QuerySet.exists() for combined querysets.
Supported since 84c1826ded.
2020-11-16 15:15:41 +01:00
David-Wobrock 464a4c0c59 Fixed #31496 -- Fixed QuerySet.values()/values_list() crash on combined querysets ordered by annotations. 2020-11-14 10:22:09 +01:00
Hasan Ramezani 3f7b327562 Fixed #31235 -- Made assertQuerysetEqual() compare querysets directly.
This also replaces assertQuerysetEqual() to
assertSequenceEqual()/assertCountEqual() where appropriate.

Co-authored-by: Peter Inglesby <peter.inglesby@gmail.com>
Co-authored-by: Mariusz Felisiak <felisiak.mariusz@gmail.com>
2020-11-06 09:24:50 +01:00
Simon Charette 8593e162c9 Fixed #32143 -- Used EXISTS to exclude multi-valued relationships.
As mentioned in the pre-existing split_exclude() docstring EXISTS is
easier to optimize for query planers and circumvents the IN (NULL)
handling issue.
2020-10-28 07:22:00 +01:00
Simon Charette bbf141bcdc Refs #27149 -- Fixed sql.Query identity.
By making Query subclass BaseExpression in
3543129822 the former defined it's
identity based off _construct_args which is not appropriate.
2020-10-28 07:21:53 +01:00
Tim Graham 49ece89702
Fixed some queries tests when primary key values are large.
On CockroachDB, primary key values stored in these fields are larger
than they accept. Fixes:
queries.test_bulk_update.BulkUpdateNoteTests.test_multiple_fields,
queries.test_bulk_update.BulkUpdateNoteTests.test_inherited_fields, and
queries.tests.RelatedLookupTypeTests.test_values_queryset_lookup.
2020-10-27 06:39:52 +01:00
Tim Graham 73be11a266
Removed an obsolete query test that assumes serial pks.
The code from the original fix (922aba3def)
was removed in 419de7b00d.
2020-10-27 06:31:26 +01:00
Hannes Ljungberg c7c7615d00 Fixed #32116 -- Fixed QuerySet.order_by() crash on EmptyQuerySet with union() on a single non-empty ordered queryset. 2020-10-19 08:36:07 +02:00
Hasan Ramezani 981a3426cf Fixed #32068 -- Added error messages on get() with filters following union(), intersection(), and difference(). 2020-10-05 12:25:05 +02:00
Hasan Ramezani 7cfa40d872 Refs #32068 -- Added tests for get() following union(), intersection(), and difference(). 2020-10-05 12:25:02 +02:00
Hasan Ramezani a046bcadbe
Fixed #31916 -- Fixed combined queryset crash when combining with ordered combined querysets. 2020-09-17 08:26:06 +02:00
Kwist 981a072dd4 Fixed #31843 -- Fixed pickling named values from QuerySet.values_list(). 2020-09-16 13:43:06 +02:00
Mariusz Felisiak e11d05e0b4
Fixed #31990 -- Fixed QuerySet.ordered for GROUP BY queries on models with Meta.ordering.
Regression in 0ddb4ebf7b.

Thanks Julien Dutriaux for the report.
2020-09-14 20:07:44 +02:00
Nick Pope b312421511
Refs #30897 -- Added test for WAL option to Queryset.explain() on PostgreSQL 13+. 2020-08-24 11:47:38 +02:00
Alexandr Tatarinov f4ac167119 Fixed #27719 -- Added QuerySet.alias() to allow creating reusable aliases.
QuerySet.alias() allows creating reusable aliases for expressions that
don't need to be selected but are used for filtering, ordering, or as
a part of complex expressions.

Thanks Simon Charette for reviews.
2020-07-31 13:19:33 +02:00
Hasan Ramezani 9c9a3fe118 Fixed #31783 -- Fixed crash when filtering againts "negate" field.
Thanks Simon Charette for the initial patch.
2020-07-29 08:20:58 +02:00
Mariusz Felisiak ae8338daf3
Fixed #31767 -- Fixed QuerySet.none() on combined queryset. 2020-07-07 12:15:05 +02:00
Jacob Walls 512da9d585 Fixed #23797 -- Fixed QuerySet.exclude() when rhs is a nullable column. 2020-07-06 10:15:37 +02:00
Nicolas Baccelli b38d44229f Fixed #31664 -- Reallowed using non-expressions having filterable attribute as rhs in queryset filters.
Regression in 4edad1ddf6.
2020-06-08 08:17:23 +02:00
Mariusz Felisiak f4bab0982a Refs #31614 -- Added test for ordering by OrderBy() of combined queryset with not selected columns. 2020-05-27 09:03:53 +02:00
Laurent Tramoy 2aac176e86 Fixed #31614 -- Fixed aliases ordering by OrderBy() expressions of combined queryset. 2020-05-26 21:14:45 +02:00
Laurent Tramoy 51ad767d0b Refs #31614 -- Added test for aliases ordering on combined querysets. 2020-05-26 21:14:40 +02:00
Laurent Tramoy 50f71ccb36 Used operator.attrgetter() in test_qs_combinators. 2020-05-26 21:14:40 +02:00
Mariusz Felisiak 20a8a443f0
Fixed #31578 -- Dropped support for MySQL 5.6. 2020-05-19 10:56:39 +02:00
Simon Charette 94f63b926f Refs #31395 -- Relied on setUpTestData() test data isolation in various tests. 2020-05-15 20:22:56 +02:00
Simon Charette 1dd96f731d Refs #13227 -- Adjusted a test to avoid making a shared test model unpickable.
This allowed the Note model to be used in setUpTestData() which requires
assigned model instances to be copy.deepcopy()'able.
2020-05-15 20:22:51 +02:00
Hasan Ramezani 01a381cc17
Fixed #31580 -- Added error messages on distinct() following union(), intersection(), and difference(). 2020-05-13 14:44:10 +02:00
sage 6789ded0a6 Fixed #12990, Refs #27694 -- Added JSONField model field.
Thanks to Adam Johnson, Carlton Gibson, Mariusz Felisiak, and Raphael
Michel for mentoring this Google Summer of Code 2019 project and
everyone else who helped with the patch.

Special thanks to Mads Jensen, Nick Pope, and Simon Charette for
extensive reviews.

Co-authored-by: Mariusz Felisiak <felisiak.mariusz@gmail.com>
2020-05-08 07:23:31 +02:00
Nick Pope 8f10ceaa90 Changed `'%s' % value` pattern to `str(value)`. 2020-05-04 08:27:18 +02:00
Simon Charette 513948735b Fixed #31426 -- Added proper field validation to QuerySet.order_by().
Resolve the field reference instead of using fragile regex based string
reference validation.
2020-04-06 10:19:49 +02:00