summaryrefslogtreecommitdiff
path: root/django/db/models/sql
AgeCommit message (Collapse)Author
2020-08-11[3.0.x] Fixed #31866 -- Fixed locking proxy models in ↵Daniel Hillier
QuerySet.select_for_update(of=()). Backport of 60626162f76f26d32a38d18151700cb041201fb3 from master
2020-06-08[3.0.x] Fixed #31664 -- Reallowed using non-expressions having filterable ↵Nicolas Baccelli
attribute as rhs in queryset filters. Regression in 4edad1ddf6203326e0be4bdb105beecb0fe454c4. Backport of b38d44229ff185ad156bcb443d6db0db7ae3eb98 from master
2020-05-14[3.0.x] Fixed #31584 -- Fixed crash when chaining values()/values_list() ↵Mariusz Felisiak
after Exists() annotation and aggregation on Oracle. Oracle requires the EXISTS expression to be wrapped in a CASE WHEN in the GROUP BY clause. Regression in efa1908f662c19038a944129c81462485c4a9fe8. Backport of 3a941230c85b2702a5e1cd97e17251ce21057efa from master
2020-05-14[3.0.x] Fixed #31568 -- Fixed alias reference when aggregating over multiple ↵Simon Charette
subqueries. 691def10a0197d83d2d108bd9043b0916d0f09b4 made all Subquery() instances equal to each other which broke aggregation subquery pushdown which relied on object equality to determine which alias it should select. Subquery.__eq__() will be fixed in an another commit but Query.rewrite_cols() should haved used object identity from the start. Refs #30727, #30188. Thanks Makina Corpus for the report. Backport of adfbf653dc1c1d0e0dacc4ed46602d22ba28b004 from master
2020-05-14[3.0.x] Fixed #31566 -- Fixed aliases crash when chaining ↵Simon Charette
values()/values_list() after annotate() with aggregations and subqueries. Subquery annotation references must be resolved if they are excluded from the GROUP BY clause by a following .values() call. Regression in fb3f034f1c63160c0ff13c609acd01c18be12f80. Thanks Makina Corpus for the report. Backport of 42c08ee46539ef44f8658ebb1cbefb408e0d03fe from master
2020-04-06[3.0.x] Fixed #31420 -- Fixed crash when filtering subquery annotation ↵Hasan Ramezani
against a SimpleLazyObject. Thanks Simon Charette for the solution and analysis. Backport of 4237050684427db45ea834fe89d9e11c0520201e from master
2020-03-25[3.0.x] Fixed #31377 -- Disabled grouping by aliases on ↵Hasan Ramezani
QuerySet.values()/values_list() when they collide with field names. Regression in fb3f034f1c63160c0ff13c609acd01c18be12f80. Thanks Holovashchenko Vadym for the report. Backport of 10866a10fe9f0ad3ffdf6f93823aaf4716e6f27c from master
2020-02-11[3.0.x] Fixed #31246 -- Fixed locking models in ↵Abhijeet Viswa
QuerySet.select_for_update(of=()) for related fields and parent link fields with multi-table inheritance. Partly regression in 0107e3d1058f653f66032f7fd3a0bd61e96bf782. Backport of 1712a76b9dfda1ef220395e62ea87079da8c9f6c from master
2020-02-03[3.0.x] Fixed #31217 -- Made QuerySet.values()/values_list() group by not ↵Mariusz Felisiak
selected annotations with aggregations used in order_by(). Regression in 59b4e99dd00b9c36d56055b889f96885995e4240. Thanks Jon Dufresne for the report and Simon Charette for the review. Backport of 6b178a3e930f72069f3cda2e6a09d1b320fc09ec from master
2020-01-15[3.0.x] Refs #31136 -- Made QuerySet.values()/values_list() group only by ↵Mariusz Felisiak
selected annotation. Regression in 0f843fdd5b9b2f2307148465cd60f4e1b2befbb4. Backport of 59b4e99dd00b9c36d56055b889f96885995e4240 from master
2020-01-04[3.0.x] Fixed #31136 -- Disabled grouping by aliases on ↵Mariusz Felisiak
QuerySet.values()/values_list(). Regression in fb3f034f1c63160c0ff13c609acd01c18be12f80. Thanks Sigurd Ljødal for the report. Backport of 0f843fdd5b9b2f2307148465cd60f4e1b2befbb4 from master
2019-12-23[3.0.x] Fixed #31109 -- Disabled grouping by aliases on QuerySet.exists().Simon Charette
Clearing the SELECT clause in Query.has_results was orphaning GROUP BY references to it. Thanks Thierry Bastian for the report and Baptiste Mispelon for the bisect. Regression in fb3f034f1c63160c0ff13c609acd01c18be12f80. Backport of 720de4d0441fcfdb543051389c70efbe66ed962a from master
2019-12-19[3.0.x] Fixed #31094 -- Included columns referenced by subqueries in GROUP ↵Simon Charette
BY on aggregations. Thanks Johannes Hoppe for the report. Regression in fb3f034f1c63160c0ff13c609acd01c18be12f80. Co-authored-by: Mariusz Felisiak <felisiak.mariusz@gmail.com> Backport of 5a4d7285bd10bd40d9f7e574a7c421eb21094858 from master
2019-12-06[3.0.x] Fixed #31060 -- Reallowed window expressions to be used in ↵Alex Aktsipetrov
conditions outside of queryset filters. Regression in 4edad1ddf6203326e0be4bdb105beecb0fe454c4. Thanks utapyngo for the report. Backport of bf12273db4e53779546e2ac7b65c0ce8e3c8a640 from master.
2019-12-02[3.0.x] Fixed #30953 -- Made select_for_update() lock queryset's model when ↵Mariusz Felisiak
using "self" with multi-table inheritance. Thanks Abhijeet Viswa for the report and initial patch. Backport of 0107e3d1058f653f66032f7fd3a0bd61e96bf782 from master
2019-11-13[3.0.x] Fixed #30971 -- Prevented Query.resolve_lookup_value() from coercing ↵George Marshall
list values to tuples. Regression in 8a281aa7fe76a9da2284f943964a9413697cff1f. Backport of 8be79984dce7d819879a6e594ca69c5f95a08378 from master
2019-10-11[3.0.x] Fixed #30854 -- Fixed QuerySet.select_related() with multiple ↵Hasan Ramezani
FilteredRelations. Backport of 6a75cea76a98c08bf2e20d787be9b14c2cd94860 from master.
2019-09-24[3.0.x] Fixed #30796 -- Prevented select_related() from mutating a queryset ↵Simon Charette
on chaining. Thanks Darren Maki for the report. Backport of 37f8f293775d0b672da8ae369d9a4e17f1db7851 from master
2019-09-09Fixed #28107 -- Added ↵Vojtech Bocek
DatabaseFeatures.allows_group_by_selected_pks_on_model() to allow enabling optimization for unmanaged models.
2019-09-09Refs #29444 -- Allowed returning multiple fields from INSERT statements on ↵Johannes Hoppe
PostgreSQL. Thanks Florian Apolloner, Tim Graham, Simon Charette, Nick Pope, and Mariusz Felisiak for reviews.
2019-09-02Fixed #30739 -- Fixed exclusion of multi-valued lookup against outer rhs.Simon Charette
OuterRef right hand sides have to be nested, just like F rhs have to, during the subquery pushdown split_exclude performs to ensure they are resolved against the outer query aliases.
2019-08-29Fixed #25367 -- Allowed boolean expressions in QuerySet.filter() and exclude().Matthew Schinckel
This allows using expressions that have an output_field that is a BooleanField to be used directly in a queryset filters, or in the When() clauses of a Case() expression. Thanks Josh Smeaton, Tim Graham, Simon Charette, Mariusz Felisiak, and Adam Johnson for reviews. Co-Authored-By: NyanKiyoshi <hello@vanille.bid>
2019-08-17Fixed #29545 -- Fixed using filter lookups againts nested subquery expressions.Simon Charette
Made sql.Where resolve lhs of its child nodes. This is necessary to allow filter lookups against nested subquery expressions to properly resolve their OuterRefs to Cols. Thanks Oskar Persson for the simplified test case.
2019-08-16Fixed #30687 -- Fixed using of OuterRef() expressions in distance lookups.Andrew Brown
2019-08-13Refs #25367 -- Moved select_format hook to BaseExpression.Simon Charette
This will expose an intermediary hook for expressions that need special formatting when used in a SELECT clause.
2019-08-02Fixed #30668 -- Made QuerySet.filter() raise NotSupportedError if any of ↵aaktsipetrov
source expressions is not filterable.
2019-07-25Added Query.is_sliced property.Mariusz Felisiak
Previously, we used Query.can_filter() mainly to check if a query is sliced what was confusing.
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-07-08Refs #29444 -- Added support for fetching a returned non-integer insert ↵Johannes Hoppe
values on Oracle. This is currently not actively used, since the ORM will ask the SQL compiler to only return auto fields.
2019-06-28Fixed #28408 -- Added error message when updating with annotated expressions ↵can
on joined fields. Co-Authored-By: Simon Charette <charette.s@gmail.com>
2019-06-19Fixed #29834 -- Fixed column mismatch crash with ↵can
QuerySet.values()/values_list() and order_by() on combined querysets.
2019-06-19Fixed #30572 -- Prevented values()/values_list() on combined queryset from ↵Mariusz Felisiak
mutating the list of columns in querysets.
2019-05-31Fixed #26192 -- Fixed crash of ordering by constants on PostgreSQL.Mariusz Felisiak
Thanks Simon Charette for the review.
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.
2019-05-07Fixed #30349 -- Fixed QuerySet.exclude() on FilteredRelation.Rob
Using annotated FilteredRelations raised a FieldError when coupled with exclude(). This is due to not passing filtered relation fields to the subquery created in split_exclude(). We fixed this issue by passing the filtered relation data to the newly created subquery. Secondly, in the case where an INNER JOIN is used in the excluded subquery, the ORM would trim the filtered relation INNER JOIN in attempt to simplify the query. This will also remove the ON clause filters generated by the FilteredRelation. We added logic to not trim the INNER JOIN if it is from FilteredRelation.
2019-05-03Fixed #29692 -- Fixed removing ordering parts for multiline RawSQL expressions.can
2019-04-30Fixed #30412 -- Fixed crash when adding check constraints with OR'ed ↵can
condition on Oracle and SQLite.
2019-04-23Fixed #29810 -- Fixed crash of select_related() on FilteredRelation with ↵can
empty result.
2019-04-18Fixed #30335, #29139 -- Fixed crash when ordering or aggregating over a ↵can
nested JSONField key transform.
2019-04-15Refs #23758 -- Used RecursionError instead of RuntimeError to raise nested ↵Simon Charette
subquery errors. RecursionError was introduced in Python 3.5 and subclasses RuntimeError.
2019-04-15Refs #27149 -- Based recursive nested subquery detection on ↵Simon Charette
sys.getrecursionlimit(). This makes sure the test_avoid_infinite_loop_on_too_many_subqueries test doesn't fail on systems with a non-default recursion limit.
2019-03-23Fixed #30246 -- Reused annotation aliases references in aggregation filters.Simon Charette
Thanks Jan Baryła for the detailed report and the reduced test case.
2019-03-23Refs #30188 -- Avoided GROUP BY when aggregating over non-aggregates.Simon Charette
2019-03-23Refs #30188 -- Prevented double annotation of subquery when aggregated over.Simon Charette
Thanks Can Sarıgöl for the suggested trimming approach.
2019-03-23Fixed #30188 -- Fixed a crash when aggregating over a subquery annotation.Simon Charette
2019-03-23Fixed #21703 -- Fixed a crash when excluding a related field with a F().Simon Charette
2019-03-21Removed obsolete Lookup hook to prepare rhs expressions.Simon Charette
After 3a505c70e7b228bf1212c067a8f38271ca86ce09, all _prepare() methods return self.
2019-03-21Refs #27149, #29542 -- Simplified subquery parentheses wrapping logic.Simon Charette