summaryrefslogtreecommitdiff
path: root/tests/aggregation
diff options
context:
space:
mode:
authorLuke Plant <L.Plant.98@cantab.net>2021-12-29 14:00:50 +0000
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2022-03-31 11:05:23 +0200
commit40b8a6174f001a310aa33f7880db0efeeb04d4c4 (patch)
tree2a4a940f81dbab0fb3723b1d4de9d4db04f9894e /tests/aggregation
parent1efea11808f7b8a3b31445e0c1c7d270f832d965 (diff)
downloaddjango-40b8a6174f001a310aa33f7880db0efeeb04d4c4.tar.gz
Fixed #33397 -- Corrected resolving output_field for DateField/DateTimeField/TimeField/DurationFields.
This includes refactoring of CombinedExpression._resolve_output_field() so it no longer uses the behavior inherited from Expression of guessing same output type if argument types match, and instead we explicitly define the output type of all supported operations. This also makes nonsensical operations involving dates (e.g. date + date) raise a FieldError, and adds support for automatically inferring output_field for cases such as: * date - date * date + duration * date - duration * time + duration * time - time
Diffstat (limited to 'tests/aggregation')
-rw-r--r--tests/aggregation/tests.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/tests/aggregation/tests.py b/tests/aggregation/tests.py
index b779fe551c..3922478bf3 100644
--- a/tests/aggregation/tests.py
+++ b/tests/aggregation/tests.py
@@ -1126,8 +1126,8 @@ class AggregateTestCase(TestCase):
def test_combine_different_types(self):
msg = (
- "Expression contains mixed types: FloatField, DecimalField. "
- "You must set output_field."
+ "Cannot infer type of '+' expression involving these types: FloatField, "
+ "DecimalField. You must set output_field."
)
qs = Book.objects.annotate(sums=Sum("rating") + Sum("pages") + Sum("price"))
with self.assertRaisesMessage(FieldError, msg):