From 38fce49c82858d2cac810679d1c0e518840a8615 Mon Sep 17 00:00:00 2001 From: Simon Charette Date: Sun, 30 Aug 2020 22:25:54 -0400 Subject: [PATCH] Fixed #31919 -- Resolved output_field of IntegerField subclasses combinations. --- django/db/models/expressions.py | 1 + tests/expressions/tests.py | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/django/db/models/expressions.py b/django/db/models/expressions.py index a9768919a2..90d90119d0 100644 --- a/django/db/models/expressions.py +++ b/django/db/models/expressions.py @@ -421,6 +421,7 @@ class Expression(BaseExpression, Combinable): _connector_combinators = { connector: [ + (fields.IntegerField, fields.IntegerField, fields.IntegerField), (fields.IntegerField, fields.DecimalField, fields.DecimalField), (fields.DecimalField, fields.IntegerField, fields.DecimalField), (fields.IntegerField, fields.FloatField, fields.FloatField), diff --git a/tests/expressions/tests.py b/tests/expressions/tests.py index 42b6b828f4..0ae61a6506 100644 --- a/tests/expressions/tests.py +++ b/tests/expressions/tests.py @@ -9,8 +9,8 @@ from unittest import mock from django.core.exceptions import FieldError from django.db import DatabaseError, NotSupportedError, connection from django.db.models import ( - Avg, BinaryField, BooleanField, Case, CharField, Count, DateField, - DateTimeField, DecimalField, DurationField, Exists, Expression, + AutoField, Avg, BinaryField, BooleanField, Case, CharField, Count, + DateField, DateTimeField, DecimalField, DurationField, Exists, Expression, ExpressionList, ExpressionWrapper, F, FloatField, Func, IntegerField, Max, Min, Model, OrderBy, OuterRef, Q, StdDev, Subquery, Sum, TimeField, UUIDField, Value, Variance, When, @@ -1893,6 +1893,8 @@ class CombinableTests(SimpleTestCase): class CombinedExpressionTests(SimpleTestCase): def test_resolve_output_field(self): tests = [ + (IntegerField, AutoField, IntegerField), + (AutoField, IntegerField, IntegerField), (IntegerField, DecimalField, DecimalField), (DecimalField, IntegerField, DecimalField), (IntegerField, FloatField, FloatField),