#26498 closed Bug (fixed)
Data loss of microseconds on MySQL and SQLite
Reported by: | Adam Johnson | Owned by: | nobody |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | 1.8 |
Severity: | Normal | Keywords: | |
Cc: | me@… | Triage Stage: | Accepted |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | yes |
Easy pickings: | no | UI/UX: | no |
Pull Requests: | |||
Description ¶
Django provides django.db.backends.utils.typecast_time
as a converter function for MySQL and SQLite. This function uses floating point logic which unfortunately causes loss of precision on some values, for example:
In [1]: from django.db.backends.utils import typecast_time In [2]: typecast_time('12:45:30.126631') # okay Out[2]: datetime.time(12, 45, 30, 126631) In [3]: typecast_time('12:45:30.126630') # woops Out[3]: datetime.time(12, 45, 30, 126629)
This will probably only cause loss of a single microsecond, but it's annoying that the database doesn't roundtrip values.
Change History (10)
comment:1 by , 9 years ago
comment:2 by , 9 years ago
Has patch: | set |
---|---|
Triage Stage: | Unreviewed → Accepted |
Type: | Uncategorized → Bug |
Version: | 1.8 → master |
comment:3 by , 9 years ago
Triage Stage: | Accepted → Ready for checkin |
---|
comment:4 by , 9 years ago
Should this be backported? Typically that's what we do for data loss issues.
comment:6 by , 9 years ago
Patch needs improvement: | set |
---|---|
Triage Stage: | Ready for checkin → Accepted |
comment:7 by , 9 years ago
Version: | master → 1.8 |
---|
Note:
See TracTickets
for help on using tickets.
https://github.com/django/django/pull/6450