Opened 7 years ago

Closed 7 years ago

#28967 closed Bug (fixed)

Cast with FloatField rounds value to integer on MySQL

Reported by: Sergey Fedoseev Owned by: Sergey Fedoseev
Component: Database layer (models, ORM) Version: 1.10
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

In [6]: DurationModel.objects.annotate(f=models.functions.Cast(0.125, models.FloatField())).first().f
Out[6]: 0.0

In [7]: DurationModel.objects.annotate(f=models.functions.Cast(0.5, models.FloatField())).first().f
Out[7]: 1.0

Change History (4)

comment:1 by Sergey Fedoseev, 7 years ago

Owner: changed from nobody to Sergey Fedoseev
Status: newassigned

comment:2 by Tim Graham, 7 years ago

Triage Stage: UnreviewedAccepted

comment:3 by Sergey Fedoseev, 7 years ago

comment:4 by Tim Graham <timograham@…>, 7 years ago

Resolution: fixed
Status: assignedclosed

In 44908d4:

Fixed #28967 -- Prevented Cast to FloatField from rounding to integer on MySQL.

Note: See TracTickets for help on using tickets.
Back to Top