Commit Graph

147 Commits

Author SHA1 Message Date
Mariusz Felisiak 3278c31fa5 [4.0.x] Refs #33476 -- Refactored code to strictly match 88 characters line length.
Backport of 7119f40c98 from main.
2022-02-08 19:25:02 +01:00
django-bot 6a682b38e7 [4.0.x] Refs #33476 -- Reformatted code with Black.
Backport of 9c19aff7c7 from main.
2022-02-08 12:15:38 +01:00
Mariusz Felisiak d55a1e5809 [4.0.x] Refs #33476 -- Refactored problematic code before reformatting by Black.
In these cases Black produces unexpected results, e.g.

def make_random_password(
    self,
    length=10,
    allowed_chars='abcdefghjkmnpqrstuvwxyz' 'ABCDEFGHJKLMNPQRSTUVWXYZ' '23456789',
):

or

cursor.execute("""
SELECT ...
""",
    [table name],
)

Backport of c5cd878382 from main.
2022-02-03 11:38:46 +01:00
Mariusz Felisiak e703b152c6
Fixed #32793 -- Fixed loss of precision for temporal operations with DecimalFields on MySQL.
Regression in 1e38f1191d.

Thanks Mohsen Tamiz for the report.
2021-06-01 15:11:42 +02:00
Mariusz Felisiak f0a9413bd2 Refs #24121 -- Improved Value.__repr__(). 2021-05-24 07:26:53 +02:00
Mariusz Felisiak 3f6d4e22f8 Fixed typo in tests/expressions/tests.py. 2021-05-24 07:26:53 +02:00
Simon Charette 96f55ccf79 Fixed #32714 -- Prevented recreation of migration for Meta.ordering with OrderBy expressions.
Regression in c8b6594305.

Thanks Kevin Marsh for the report.
2021-05-05 08:43:57 +02:00
Tobias Bengfort 54e94640ac Refs #25287 -- Added support for multiplying and dividing DurationField by scalar values on SQLite. 2021-04-20 11:44:41 +02:00
Hasan Ramezani ed0cc52dc3 Fixed #32585 -- Fixed Value() crash with DecimalField on SQLite. 2021-03-29 06:22:36 +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 54f60bc85d Refs #32548 -- Added tests for passing conditional expressions to Q(). 2021-03-17 21:53:36 +01:00
Hasan Ramezani f2bef2b7bc Fixed #32455 -- Allowed right combining Q() with boolean expressions. 2021-02-18 22:20:36 +01:00
Mariusz Felisiak efce21497c Refs #32455 -- Added tests for left combining an empty Q() with boolean expressions. 2021-02-18 22:19:56 +01:00
Mariusz Felisiak b989d21336
Refs #26602 -- Added tests for aggregating over a RawSQL() annotation.
Fixed in 3f32154f40.

Thanks Manav Agarwal for initial test.
2021-01-26 10:59:05 +01:00
Mariusz Felisiak 5e33ec80d1 Refs #30158 -- Made alias argument required in signature of Expression.get_group_by_cols() subclasses.
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
Ian Foote 8b040e3cbb Fixed #25534, Fixed #31639 -- Added support for transform references in expressions.
Thanks Mariusz Felisiak and Simon Charette for reviews.
2020-11-27 20:42:04 +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
Adam Johnson a56586eafe Fixed #32134 -- Fixed crash of __range lookup with namedtuple.
Regression in 8be79984dc.

Thanks Gordon Wrigley for the report.
2020-10-23 18:01:31 +02:00
Tim Graham afcad0f1b1
Relaxed some query ordering assertions in expressions tests.
It accounts for differences seen on CockroachDB.
2020-10-19 19:21:31 +02:00
Nick Pope 06c5d3fafc Fixed #32060 -- Added Random database function. 2020-10-02 06:58:03 +02:00
Simon Charette 38fce49c82 Fixed #31919 -- Resolved output_field of IntegerField subclasses combinations. 2020-08-31 06:42:40 +02:00
Simon Charette 40894f2967 Refs #30446 -- Added tests for resolving output_field of CombinedExpression. 2020-08-31 06:40:39 +02:00
Simon Charette 51297a9232 Fixed #31792 -- Made Exists() reuse QuerySet.exists() optimizations.
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-13 14:10:36 +02:00
Simon Charette 156a2138db Refs #30446 -- Removed unnecessary Value(..., output_field) in docs and tests. 2020-07-15 10:58:38 +02: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
Simon Charette f783a99072 Refs #25425 -- Allowed unresolved Value() instances to be compiled.
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.
2020-07-14 07:20:20 +02:00
Sergey Fedoseev 9d519d3dc4 Fixed #31755 -- Made temporal subtraction resolve output field. 2020-07-01 23:02:27 +02:00
Sergey Fedoseev ed6b14d459
Refs #28621 -- Fixed crash of annotations with nested OuterRef. 2020-07-01 11:01:46 +02:00
Sergey Fedoseev dd5aa8cb5f Fixed #28925 -- Fixed durations-only expressions crash on SQLite and MySQL.
This removes also unused DatabaseOperations.date_interval_sql().
2020-06-30 07:04:55 +02:00
Mariusz Felisiak aeb8996a67 Fixed #31659 -- Made ExpressionWrapper preserve output_field for combined expressions.
Regression in df32fd42b8.

Thanks Simon Charette for the review.
2020-06-12 07:20:06 +02:00
Thodoris Sotiropoulos df32fd42b8 Fixed #31651 -- Made ExpressionWrapper use grouping columns from wrapped expression. 2020-06-03 07:29:41 +02:00
Mariusz Felisiak a125da6a7c Fixed #31607 -- Fixed evaluated Subquery equality.
Regression in 691def10a0.
2020-05-19 22:44:57 +02:00
Nick Pope 8f10ceaa90 Changed `'%s' % value` pattern to `str(value)`. 2020-05-04 08:27:18 +02:00
Mariusz Felisiak 555e3a848e
Removed unused __str__() methods in tests models.
Follow up to 6461583b6c.
2020-04-30 09:13:23 +02:00
Hasan Ramezani 4237050684 Fixed #31420 -- Fixed crash when filtering subquery annotation against a SimpleLazyObject.
Thanks Simon Charette for the solution and analysis.
2020-04-06 07:11:29 +02:00
Hasan Ramezani 6fbce45b03 Fixed #31415 -- Fixed crash when nested OuterRef is used with operators or in database functions. 2020-04-04 20:16:00 +02:00
Mariusz Felisiak ab5720ad80
Removed unnecessary assertions in ExpressionOperatorTests.
These tests don't modify Number.float field.
2020-03-25 13:12:32 +01:00
Hannes Ljungberg f3da09df0f Fixed #31396 -- Added binary XOR operator to F expressions. 2020-03-25 10:16:30 +01:00
Rohit 486786c4c4 Fixed #31251 -- Disabled grouping by OuterRef() annotation. 2020-02-27 13:02:49 +01:00
Simon Charette 41ebe60728 Fixed #31312 -- Properly ordered temporal subtraction params on MySQL.
Regression in 9bcbcd599a.

Thanks rick2ricks for the report.
2020-02-27 08:50:55 +01:00
Nick Pope 335c9c94ac Simplified imports from django.db and django.contrib.gis.db. 2020-02-04 13:20:06 +01:00
Simon Charette 9bcbcd599a Fixed #31133 -- Fixed crash when subtracting against a subquery annotation.
The subtract_temporals() database operation was not handling expressions
returning SQL params in mixed database types.

Regression in 3543129822.

Thanks Reupen Shah for the report.
2020-01-03 10:35:08 +01:00
Mariusz Felisiak 45bcc6feac
Refs #31115 -- Added test for nested subquery that references related fields.
Thanks Dmitriy Gunchenko for the report and Simon Charette for the
analysis and tests.

Regression in 5a4d7285bd.

Fixed in 5a4d7285bd.
2019-12-23 12:17:56 +01:00
Mariusz Felisiak 8685e764ef Fixed #30986 -- Fixed queryset crash when filtering against boolean RawSQL expressions on Oracle. 2019-11-18 08:50:09 +01:00
Min ho Kim 103a6f4307 Fixed some typos in comments and docs.
Thanks to Mads Jenson for review.
2019-10-02 15:50:46 +02:00
ElizabethU 54ea290e5b Fixed #30651 -- Made __eq__() methods return NotImplemented for not 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.
2019-10-01 17:58:19 +02:00
Matthew Schinckel 4137fc2efc Fixed #25367 -- Allowed boolean expressions in QuerySet.filter() and exclude().
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-29 09:45:29 +02:00
Mariusz Felisiak 069bee7c12
Used skipUnlessDBFeature instead of checking vendor in test_filtering_on_annotate_that_uses_q. 2019-08-29 09:40:34 +02:00
Simon Charette ee6e93ec87 Fixed #30628 -- Adjusted expression identity to differentiate bound fields.
Expressions referring to different bound fields should not be
considered equal.

Thanks Julien Enselme for the detailed report.

Regression in bc7e288ca9.
2019-07-10 07:46:08 +02:00