summaryrefslogtreecommitdiff
path: root/django/db/models/expressions.py
Commit message (Collapse)AuthorAgeFilesLines
...
* Fixed #31507 -- Added QuerySet.exists() optimizations to compound queries.David-Wobrock2020-11-161-4/+11
|
* Fixed #32143 -- Used EXISTS to exclude multi-valued relationships.Simon Charette2020-10-281-5/+4
| | | | | | As mentioned in the pre-existing split_exclude() docstring EXISTS is easier to optimize for query planers and circumvents the IN (NULL) handling issue.
* Fixed #32126 -- Fixed grouping by Case() annotation without cases.Hannes Ljungberg2020-10-211-0/+5
| | | | Co-authored-by: Simon Charette <charettes@users.noreply.github.com>
* Refs #32096 -- Fixed ExpressionWrapper crash with JSONField key transforms.Mariusz Felisiak2020-10-141-1/+1
| | | | | | Regression in 6789ded0a6ab797f0dcdfa6ad5d1cfa46e23abcd. Thanks Simon Charette and Igor Jerosimić for the report.
* Fixed #32060 -- Added Random database function.Nick Pope2020-10-021-10/+0
|
* Fixed #31723 -- Fixed window functions crash with DecimalField on SQLite.Hasan Ramezani2020-09-231-1/+11
| | | | Thanks Simon Charette for the initial patch.
* Fixed #31919 -- Resolved output_field of IntegerField subclasses combinations.Simon Charette2020-08-311-0/+1
|
* Fixed #31792 -- Made Exists() reuse QuerySet.exists() optimizations.Simon Charette2020-08-131-3/+1
| | | | | | 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.
* Fixed #30446 -- Resolved Value.output_field for stdlib types.Simon Charette2020-07-151-7/+59
| | | | | | 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.
* Refs #25425 -- Allowed unresolved Value() instances to be compiled.Simon Charette2020-07-141-0/+4
| | | | | | | | | | Previously unresolved Value() instances were only allowed to be compiled if they weren't initialized with an output_field. Given the usage of unresolved Value() instances is relatively common in as_sql() overrides it's less controversial to add explicit support for this previously undefined behavior now and revisit whether or not it should be deprecated in the future.
* Fixed #31773 -- Fixed preserving output_field in ExpressionWrapper for ↵Mariusz Felisiak2020-07-091-4/+3
| | | | | | | | combined expressions. Thanks Thodoris Sotiropoulos for the report and Simon Charette for the implementation idea. Regression in df32fd42b84cc6dbba173201f244491b0d154a63.
* Fixed #31755 -- Made temporal subtraction resolve output field.Sergey Fedoseev2020-07-011-19/+24
|
* Refs #28621 -- Fixed crash of annotations with nested OuterRef.Sergey Fedoseev2020-07-011-0/+2
|
* Fixed #28925 -- Fixed durations-only expressions crash on SQLite and MySQL.Sergey Fedoseev2020-06-301-22/+16
| | | | This removes also unused DatabaseOperations.date_interval_sql().
* Refs #28925 -- Simplified CombinedExpression.as_sql() a bit.Sergey Fedoseev2020-06-301-10/+10
|
* Fixed #31659 -- Made ExpressionWrapper preserve output_field for combined ↵Mariusz Felisiak2020-06-121-0/+3
| | | | | | | | expressions. Regression in df32fd42b84cc6dbba173201f244491b0d154a63. Thanks Simon Charette for the review.
* Fixed #31660 -- Fixed queryset crash when grouping by m2o relation.Mariusz Felisiak2020-06-081-1/+3
| | | | | Regression in 3a941230c85b2702a5e1cd97e17251ce21057efa. Thanks Tomasz Szymański for the report.
* Fixed #31651 -- Made ExpressionWrapper use grouping columns from wrapped ↵Thodoris Sotiropoulos2020-06-031-0/+3
| | | | expression.
* Fixed #31606 -- Allowed using condition with lookups in When() expression.Ryan Heard2020-05-271-2/+5
|
* Fixed #31607 -- Fixed evaluated Subquery equality.Mariusz Felisiak2020-05-191-1/+8
| | | | Regression in 691def10a0197d83d2d108bd9043b0916d0f09b4.
* Fixed #31584 -- Fixed crash when chaining values()/values_list() after ↵Mariusz Felisiak2020-05-141-1/+2
| | | | | | | | 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.
* Fixed #31415 -- Fixed crash when nested OuterRef is used with operators or ↵Hasan Ramezani2020-04-041-0/+3
| | | | in database functions.
* Fixed #31396 -- Added binary XOR operator to F expressions.Hannes Ljungberg2020-03-251-0/+4
|
* Fixed #31376 -- Optimized nulls ordering when possible on SQLite and MySQL.Simon Charette2020-03-181-2/+6
| | | | | | | Both backends order NULLs first on ascending ordering and last on descending ordering which makes ORDER BY IS (NOT)? NULL wasteful when asc(nulls_first) and desc(nulls_last) are used since it prevents indice usage.
* Fixed #31150 -- Included subqueries that reference related fields in GROUP ↵Mariusz Felisiak2020-03-031-1/+14
| | | | | | | | | | BY clauses. Thanks Johannes Hoppe for the report. Regression in fb3f034f1c63160c0ff13c609acd01c18be12f80. Co-authored-by: Simon Charette <charette.s@gmail.com>
* Fixed #31251 -- Disabled grouping by OuterRef() annotation.Rohit2020-02-271-0/+3
|
* Simplified imports from django.db and django.contrib.gis.db.Nick Pope2020-02-041-2/+1
|
* Fixed #31094 -- Included columns referenced by subqueries in GROUP BY on ↵Simon Charette2019-12-191-1/+1
| | | | | | | | | | aggregations. Thanks Johannes Hoppe for the report. Regression in fb3f034f1c63160c0ff13c609acd01c18be12f80. Co-authored-by: Mariusz Felisiak <felisiak.mariusz@gmail.com>
* Refs #11964 -- Removed SimpleCol in favor of Query(alias_cols).Simon Charette2019-11-211-42/+12
| | | | | | This prevent having to pass simple_col through multiple function calls by defining whether or not references should be resolved with aliases at the Query level.
* Refs #13312 -- Simplified handling of nulls ordering on MySQL.Nick Pope2019-11-041-20/+9
| | | | | | | MySQL & MariaDB support the standard IS NULL and IS NOT NULL so the same workaround used for NULLS FIRST and NULLS LAST that is used for SQLite < 3.30.0 can be used. Thanks Simon Charette for the discussion.
* Refs #13312 -- Removed unnecessary IF wrapping in nulls_last handling on MySQL.Simon Charette2019-10-311-1/+1
| | | ISNULL function already returns 0 and 1 on MySQL.
* Fixed #30860 -- Disabled unneeded NULLS FIRST/LAST workaround on SQLite 3.30+.Simon Charette2019-10-091-4/+5
|
* Fixed #30651 -- Made __eq__() methods return NotImplemented for not ↵ElizabethU2019-10-011-1/+3
| | | | | | | | | implemented comparisons. Changed __eq__ to return NotImplemented instead of False if compared to an object of the same type, as is recommended by the Python data model reference. Now these models can be compared to ANY (or other objects with __eq__ overwritten) without returning False automatically.
* Refs #25367 -- Simplified OrderBy and Lookup by using Case() instead of ↵Mariusz Felisiak2019-08-291-5/+5
| | | | | RawSQL() on Oracle. Follow up to efa1908f662c19038a944129c81462485c4a9fe8.
* Fixed #25367 -- Allowed boolean expressions in QuerySet.filter() and exclude().Matthew Schinckel2019-08-291-1/+15
| | | | | | | | | | | 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>
* Fixed #30727 -- Made Subquery pickle without evaluating their QuerySet.Andrew Brown2019-08-271-0/+5
| | | | | Subquery expression objects, when pickled, were evaluating the QuerySet objects saved in its _constructor_args attribute.
* Refs #25367 -- Moved Oracle Exists() handling to contextual methods.Simon Charette2019-08-131-6/+18
| | | | | | | | | | | | | Oracle requires the EXISTS expression to be wrapped in a CASE WHEN in the following cases. 1. When part of a SELECT clause. 2. When part of a ORDER BY clause. 3. When compared against another expression in the WHERE clause. This commit moves the systematic CASE WHEN wrapping of Exists.as_oracle to contextual .select_format, Lookup.as_oracle, and OrderBy.as_oracle methods in order to avoid unnecessary wrapping.
* Refs #25367 -- Moved select_format hook to BaseExpression.Simon Charette2019-08-131-0/+7
| | | | | This will expose an intermediary hook for expressions that need special formatting when used in a SELECT clause.
* Refs #24793 -- Removed bogus connection argument from SQLCompiler.compile() ↵Simon Charette2019-08-121-2/+2
| | | | | | | calls. The method doesn't expect a connection object to be passed as its second argument.
* Fixed #30668 -- Made QuerySet.filter() raise NotSupportedError if any of ↵aaktsipetrov2019-08-021-2/+0
| | | | source expressions is not filterable.
* Fixed #28289 -- Fixed crash of RawSQL annotations on inherited model fields.can2019-07-111-0/+10
|
* Fixed #30628 -- Adjusted expression identity to differentiate bound fields.Simon Charette2019-07-101-1/+4
| | | | | | | | | Expressions referring to different bound fields should not be considered equal. Thanks Julien Enselme for the detailed report. Regression in bc7e288ca9554ac1a0a19941302dea19df1acd21.
* Fixed #30548 -- Improved exception when expression contains mixed types.CruxBox2019-06-101-2/+9
|
* Fixed #28621 -- Fixed crash of annotations with OuterRef.Mariusz Felisiak2019-03-271-0/+2
|
* Removed obsolete Lookup hook to prepare rhs expressions.Simon Charette2019-03-211-10/+0
| | | | | After 3a505c70e7b228bf1212c067a8f38271ca86ce09, all _prepare() methods return self.
* Refs #27149, #29542 -- Simplified subquery parentheses wrapping logic.Simon Charette2019-03-211-12/+2
|
* Refs #27149 -- Moved subquery expression resolving to Query.Simon Charette2019-03-211-53/+11
| | | | | | | | | | This makes Subquery a thin wrapper over Query and makes sure it respects the Expression source expression API by accepting the same number of expressions as it returns. Refs #30188. It also makes OuterRef usable in Query without Subquery wrapping. This should allow Query's internals to more easily perform subquery push downs during split_exclude(). Refs #21703.
* Refs #27149 -- Made Subquery store Query instead of Queryset.Simon Charette2019-03-211-23/+22
| | | | Subquery only uses Query.
* Fixed #30158 -- Avoided unnecessary subquery group by on aggregation.Simon Charette2019-03-211-0/+5
| | | | | | | Subquery annotations can be omitted from the GROUP BY clause on aggregation as long as they are not explicitly grouped against. Thanks Jonny Fuller for the report.
* Refs #30158 -- Added alias argument to Expression.get_group_by_cols().Simon Charette2019-03-211-10/+10
|