[Django] #32249: Increment of duration field not works properly

5 views
Skip to first unread message

Django

unread,
Dec 7, 2020, 6:54:09 PM12/7/20
to django-...@googlegroups.com
#32249: Increment of duration field not works properly
-------------------------------------+-------------------------------------
Reporter: azaitsev | Owner: nobody
Type: | Status: new
Uncategorized |
Component: Database | Version: 3.1
layer (models, ORM) |
Severity: Normal | Keywords: duration
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
I have a duration field in some model:

{{{
My(models.Model):
...
duration = models.DurationField(default=timedelta(seconds=0))
}}}

and I try to increment durations via F expression:

{{{
obj.duration = F('duration') + (now - some_other_datetime)
}}}

as a result, we have a value of the following format in the database:
0:18:30.233251 instead of a big integer one. So this makes that instance
of model completely unusable, any attempt of access raise an exception:
TypeError: unsupported type for timedelta microseconds component: str

--
Ticket URL: <https://code.djangoproject.com/ticket/32249>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Dec 8, 2020, 12:36:11 AM12/8/20
to django-...@googlegroups.com
#32249: Increment of duration field not works properly
-------------------------------------+-------------------------------------
Reporter: Alex Zaitsev | Owner: nobody
Type: Bug | Status: closed
Component: Database layer | Version: 3.1
(models, ORM) |
Severity: Normal | Resolution: duplicate
Keywords: duration | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* status: new => closed
* type: Uncategorized => Bug
* resolution: => duplicate


Comment:

Duplicate of #28925, fixed in dd5aa8cb5ffc0a89c4b9b8dee45c1c919d203489
(Django 3.2+).

--
Ticket URL: <https://code.djangoproject.com/ticket/32249#comment:1>

Reply all
Reply to author
Forward
0 new messages