Opened 9 years ago
Last modified 9 years ago
#26324 closed Bug
DurationField stores certain values incorrectly in sqlite — at Initial Version
Reported by: | chausner | Owned by: | nobody |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | 1.8 |
Severity: | Release blocker | Keywords: | sqlite, DurationField |
Cc: | Triage Stage: | Ready for checkin | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
When encoding certain timedelta values in a DurationField, saving the object to a sqlite database and then reading it again, DurationField returns None.
class Foo(models.Model): bar = models.DurationField() Foo.objects.create(bar=timedelta(seconds=2.05)) Foo.objects.create(bar=timedelta(seconds=3.05)) print str(Foo.objects.all()[0].length) # 'None' print str(Foo.objects.all()[1].length) # '3.05'
I can reproduce this bug with Django 1.8.5 and 1.9.3 using sqlite as database backend. It does not occur with MySQL, so it seems to be related to how sqlite stores bigints. It renders DurationField essentially useless with sqlite.
Note:
See TracTickets
for help on using tickets.