Skip to content
Browse files

[1.5.x] Fixed #19197 -- fixed convert_values() for nullable numeric f…


Cleaned up the implementation of base convert_values() a little, and
made sure it accepts None as a value for numeric fields.

There are no tests attached. The reason is that not all of the
convert_values() accept None as a value for numeric fields (for example

The reason the base convert_values() needs to accept None is that this
situation might arise in custom compilers for 3rd party backends. It
is easy to keep the convert_values() working, so lets do that.

Backpatch of 12a96bf
  • Loading branch information...
1 parent 528483c commit 1caa483914edf851137b3c1e39f4364772bd46c9 @akaariai akaariai committed
Showing with 3 additions and 5 deletions.
  1. +3 −5 django/db/backends/
8 django/db/backends/
@@ -883,16 +883,14 @@ def convert_values(self, value, field):
Coerce the value returned by the database backend into a consistent type
that is compatible with the field type.
- internal_type = field.get_internal_type()
- if internal_type == 'DecimalField':
+ if value is None:
return value
- elif internal_type == 'FloatField':
+ internal_type = field.get_internal_type()
+ if internal_type == 'FloatField':
return float(value)
elif (internal_type and (internal_type.endswith('IntegerField')
or internal_type == 'AutoField')):
return int(value)
- elif internal_type in ('DateField', 'DateTimeField', 'TimeField'):
- return value
return value
def check_aggregate_support(self, aggregate_func):

0 comments on commit 1caa483

Please sign in to comment.
Something went wrong with that request. Please try again.