[Django] #33214: Base DatabaseOperations missing format_for_duration_arithmetic() stub

11 views
Skip to first unread message

Django

unread,
Oct 20, 2021, 5:04:32 PM10/20/21
to django-...@googlegroups.com
#33214: Base DatabaseOperations missing format_for_duration_arithmetic() stub
-------------------------------------+-------------------------------------
Reporter: Tim | Owner: nobody
Graham |
Type: | Status: new
Cleanup/optimization |
Component: Database | Version: dev
layer (models, ORM) |
Severity: Normal | Keywords:
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 1
UI/UX: 0 |
-------------------------------------+-------------------------------------
When implementing a new database backend, I see the error "AttributeError:
'DatabaseOperations' object has no attribute
'format_for_duration_arithmetic'" rather than getting a message that the
method must be implemented.

The method was introduced in 57554442fe3e209c135e15dda4ea45123e579e58.

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

Django

unread,
Oct 21, 2021, 12:10:27 AM10/21/21
to django-...@googlegroups.com
#33214: Base DatabaseOperations missing format_for_duration_arithmetic() stub
-------------------------------------+-------------------------------------
Reporter: Tim Graham | Owner: nobody
Type: | Status: new
Cleanup/optimization |
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0

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

* stage: Unreviewed => Accepted


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

Django

unread,
Oct 22, 2021, 12:57:32 AM10/22/21
to django-...@googlegroups.com
#33214: Base DatabaseOperations missing format_for_duration_arithmetic() stub
-------------------------------------+-------------------------------------
Reporter: Tim Graham | Owner: Manaia
Type: | Junior
Cleanup/optimization | Status: assigned

Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Manaia Junior):

* owner: nobody => Manaia Junior
* status: new => assigned


--
Ticket URL: <https://code.djangoproject.com/ticket/33214#comment:2>

Django

unread,
Oct 22, 2021, 1:05:12 AM10/22/21
to django-...@googlegroups.com
#33214: Base DatabaseOperations missing format_for_duration_arithmetic() stub
-------------------------------------+-------------------------------------
Reporter: Tim Graham | Owner: Manaia
Type: | Junior
Cleanup/optimization | Status: assigned
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Mariusz Felisiak):

For this ticket, we need to add a stub method
`format_for_duration_arithmetic(self, sql)` to the
[https://github.com/django/django/blob/9231526af4b9825583b0d3cb943f88109fd30551/django/db/backends/base/operations.py#L14
BaseDatabaseOperations] that would raise `NotImplementedError` e.g.
{{{#!python
raise NotImplementedError('subclasses of BaseDatabaseOperations may
require a format_for_duration_arithmetic() method.')
}}}
Test for such methods are in
[https://github.com/django/django/blob/9231526af4b9825583b0d3cb943f88109fd30551/tests/backends/base/test_operations.py#L88-L118
tests/backends/base/test_operations.py].

--
Ticket URL: <https://code.djangoproject.com/ticket/33214#comment:3>

Django

unread,
Oct 22, 2021, 2:20:14 AM10/22/21
to django-...@googlegroups.com
#33214: Base DatabaseOperations missing format_for_duration_arithmetic() stub
-------------------------------------+-------------------------------------
Reporter: Tim Graham | Owner: Manaia
Type: | Junior
Cleanup/optimization | Status: assigned
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

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

* has_patch: 0 => 1
* stage: Accepted => Ready for checkin


Comment:

[https://github.com/django/django/pull/15016 PR]

--
Ticket URL: <https://code.djangoproject.com/ticket/33214#comment:4>

Django

unread,
Oct 22, 2021, 3:06:13 AM10/22/21
to django-...@googlegroups.com
#33214: Base DatabaseOperations missing format_for_duration_arithmetic() stub
-------------------------------------+-------------------------------------
Reporter: Tim Graham | Owner: Manaia
Type: | Junior
Cleanup/optimization | Status: closed

Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution: fixed

Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak <felisiak.mariusz@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"551c997feaaa293987af8b05efc3634b93305fac" 551c997]:
{{{
#!CommitTicketReference repository=""
revision="551c997feaaa293987af8b05efc3634b93305fac"
Fixed #33214 -- Added
BaseDatabaseOperations.format_for_duration_arithmetic() stub method.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/33214#comment:5>

Reply all
Reply to author
Forward
0 new messages