summaryrefslogtreecommitdiff
path: root/django/db/models/sql/compiler.py
AgeCommit message (Collapse)Author
2020-11-14Fixed #31496 -- Fixed QuerySet.values()/values_list() crash on combined ↵David-Wobrock
querysets ordered by annotations.
2020-11-04Fixed #31910 -- Fixed crash of GIS aggregations over subqueries.Simon Charette
Regression was introduced by fff5186 but was due a long standing issue. AggregateQuery was abusing Query.subquery: bool by stashing its compiled inner query's SQL for later use in its compiler which made select_format checks for Query.subquery wrongly assume the provide query was a subquery. This patch prevents that from happening by using a dedicated inner_query attribute which is compiled at a later time by SQLAggregateCompiler. Moving the inner query's compilation to SQLAggregateCompiler.compile had the side effect of addressing a long standing issue with aggregation subquery pushdown which prevented converters from being run. This is now fixed as the aggregation_regress adjustments demonstrate. Refs #25367. Thanks Eran Keydar for the report.
2020-10-02Fixed #32060 -- Added Random database function.Nick Pope
2020-09-17Fixed #31916 -- Fixed combined queryset crash when combining with ordered ↵Hasan Ramezani
combined querysets.
2020-08-31Fixed #31965 -- Adjusted multi-table fast-deletion on MySQL/MariaDB.Simon Charette
The optimization introduced in 7acef095d73 did not properly handle deletion involving filters against aggregate annotations. It initially was surfaced by a MariaDB test failure but misattributed to an undocumented change in behavior that resulted in the systemic generation of poorly performing database queries in 5b83bae031. Thanks Anton Plotkin for the report. Refs #23576.
2020-08-13Fixed #31792 -- Made Exists() reuse QuerySet.exists() optimizations.Simon Charette
The latter is already optimized to limit the number of results, avoid selecting unnecessary fields, and drop ordering if possible without altering the semantic of the query.
2020-08-11Fixed #31866 -- Fixed locking proxy models in QuerySet.select_for_update(of=()).Daniel Hillier
2020-06-10Fixed #31657 -- Fixed ordering by attnames of self-referential ForeignKeys.Hasan Ramezani
2020-05-26Fixed #31614 -- Fixed aliases ordering by OrderBy() expressions of combined ↵Laurent Tramoy
queryset.
2020-05-25Fixed #31624 -- Avoided subquery usage on QuerySet.all().delete().Simon Charette
Thanks Adam Johnson for the report. Regression in 7acef095d73322f45dcceb99afa1a4e50b520479.
2020-05-21Fixed #30375 -- Added FOR NO KEY UPDATE support to ↵Manuel Weitzman
QuerySet.select_for_update() on PostgreSQL.
2020-05-14Fixed #31584 -- Fixed crash when chaining values()/values_list() after ↵Mariusz Felisiak
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.
2020-05-11Refs #30116 -- Simplified regex match group access with Match.__getitem__().Jon Dufresne
The method has been available since Python 3.6. The shorter syntax is also marginally faster.
2020-04-22Avoided unnecessary recompilation of ordering clause regex in SQLCompiler.Adam Johnson
2020-03-31Refs #31403 -- Made SQLInsertCompiler.execute_sql() always return an ↵Adam Johnson
iterable of rows. List of tuples.
2020-03-19Fixed #31285 -- Fixed inherited Meta.ordering of "-pk".Jon Dufresne
2020-02-11Fixed #31246 -- Fixed locking models in QuerySet.select_for_update(of=()) ↵Abhijeet Viswa
for related fields and parent link fields with multi-table inheritance. Partly regression in 0107e3d1058f653f66032f7fd3a0bd61e96bf782.
2020-02-04Simplified imports from django.db and django.contrib.gis.db.Nick Pope
2020-02-03Fixed #31217 -- Made QuerySet.values()/values_list() group by not selected ↵Mariusz Felisiak
annotations with aggregations used in order_by(). Regression in 59b4e99dd00b9c36d56055b889f96885995e4240. Thanks Jon Dufresne for the report and Simon Charette for the review.
2019-12-19Fixed #31094 -- Included columns referenced by subqueries in GROUP BY on ↵Simon Charette
aggregations. Thanks Johannes Hoppe for the report. Regression in fb3f034f1c63160c0ff13c609acd01c18be12f80. Co-authored-by: Mariusz Felisiak <felisiak.mariusz@gmail.com>
2019-12-02Fixed #30953 -- Made select_for_update() lock queryset's model when using ↵Mariusz Felisiak
"self" with multi-table inheritance. Thanks Abhijeet Viswa for the report and initial patch.
2019-11-18Replaced QueryWrapper single usage with RawSQL.Simon Charette
2019-10-24Fixed #23576 -- Implemented multi-alias fast-path deletion in MySQL backend.Simon Charette
This required moving the entirety of DELETE SQL generation to the compiler where it should have been in the first place and implementing a specialized compiler on MySQL/MariaDB. The MySQL compiler relies on the "DELETE table FROM table JOIN" syntax for queries spanning over multiple tables.
2019-10-11Fixed #30854 -- Fixed QuerySet.select_related() with multiple FilteredRelations.Hasan Ramezani
2019-10-11Refs #30854 -- Moved local_setter() outside the loop in ↵Hasan Ramezani
SQLCompiler.get_related_selections().
2019-09-24Refs #29444 -- Removed redundant ↵Mariusz Felisiak
DatabaseFeatures.can_return_multiple_columns_from_insert. Unnecessary since b31e63879eb5d9717e9f890401f7222e4f00c910.
2019-09-24Fixed #29444 -- Allowed returning multiple fields from INSERT statements on ↵Johannes Hoppe
Oracle.
2019-09-10Refs #14357 -- Made Meta.ordering not affect GROUP BY queries.Mariusz Felisiak
Per deprecation timeline.
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-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-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-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-03Fixed #29692 -- Fixed removing ordering parts for multiline RawSQL expressions.can
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-03-21Refs #27149, #29542 -- Simplified subquery parentheses wrapping logic.Simon Charette
2019-02-14Fixed #29619 -- Added field names to some FieldErrors.Hasan Ramezani
2019-02-06Fixed #30159 -- Removed unneeded use of OrderedDict.Nick Pope
Dicts preserve order since Python 3.6.
2019-01-30Refs #29444 -- Renamed DatabaseFeatures.can_return_id* to be generic for ↵Johannes Hoppe
other columns.
2019-01-17Refs #28370 -- Removed support for the context arg of Field.from_db_value() ↵Tim Graham
and Expression.convert_value(). Per deprecation timeline.
2019-01-14Fixed #30093 -- Fixed ordering of combined queryset ordered by F expressions.Sergey Fedoseev
2018-12-06Fixed #29932 -- Fixed combining compound queries with sub-compound queries ↵Mariusz Felisiak
on SQLite and Oracle.
2018-09-13Refs #14357 -- Deprecated Meta.ordering affecting GROUP BY queries.Ramiro Morales
Thanks Ramiro Morales for contributing to the patch.