Data loss of microseconds on MySQL and SQLite
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)
| Has patch: |
set
|
| Triage Stage: |
Unreviewed → Accepted
|
| Type: |
Uncategorized → Bug
|
| Version: |
1.8 → master
|
| Triage Stage: |
Accepted → Ready for checkin
|
| Patch needs improvement: |
set
|
| Triage Stage: |
Ready for checkin → Accepted
|
| Resolution: |
→ fixed
|
| Status: |
new → closed
|
https://github.com/django/django/pull/6450