Opened 9 years ago

Last modified 9 years ago

#26324 closed Bug

DurationField stores certain values incorrectly in sqlite — at Version 1

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 (last modified by chausner)

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].bar) # 'None'
print str(Foo.objects.all()[1].bar) # '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.

Change History (1)

comment:1 by chausner, 9 years ago

Description: modified (diff)
Note: See TracTickets for help on using tickets.
Back to Top