[Django] #28103: Add ExtractQuarter to DateField

14 views
Skip to first unread message

Django

unread,
Apr 19, 2017, 3:44:43 PM4/19/17
to django-...@googlegroups.com
#28103: Add ExtractQuarter to DateField
-------------------------------------+-------------------------------------
Reporter: Matthew | Owner: nobody
Pava |
Type: New | Status: new
feature |
Component: Database | Version: 1.11
layer (models, ORM) |
Severity: Normal | Keywords: ORM Extract Trunc
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 1
UI/UX: 0 |
-------------------------------------+-------------------------------------
I was able to successfully add it to my project, but it seems so basic and
general that I would like to see it added to Django.

{{{
class ExtractQuarter(Extract):
lookup_name = "quarter"

DateField.register_lookup(ExtractQuarter)
}}}

You probably also want to add a corresponding Trunc function, though I
haven't tested it.
{{{
class TruncQuarter(TruncBase):
kind = "quarter"
}}}

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

Django

unread,
Apr 20, 2017, 4:40:46 AM4/20/17
to django-...@googlegroups.com
#28103: Add "quarter" lookup to DateField/DateTimeField
-------------------------------------+-------------------------------------
Reporter: Matthew Pava | Owner: nobody
Type: New feature | Status: new
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: ORM Extract Trunc | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0

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

* version: 1.11 => master
* stage: Unreviewed => Accepted


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

Django

unread,
Apr 20, 2017, 4:42:58 AM4/20/17
to django-...@googlegroups.com
#28103: Add "quarter" lookup to DateField/DateTimeField
-------------------------------------+-------------------------------------
Reporter: Matthew Pava | Owner: nobody
Type: New feature | Status: new
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: ORM Extract Trunc | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0

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

* cc: felixxm (added)


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

Django

unread,
Apr 20, 2017, 4:53:26 AM4/20/17
to django-...@googlegroups.com
#28103: Add "quarter" lookup to DateField/DateTimeField
-------------------------------------+-------------------------------------
Reporter: Matthew Pava | Owner: nobody
Type: New feature | Status: new
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: ORM Extract Trunc | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0

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

Comment (by felixxm):

You can take a look at very similar #25240 ticket.

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

Django

unread,
Apr 20, 2017, 5:46:19 PM4/20/17
to django-...@googlegroups.com
#28103: Add "quarter" lookup to DateField/DateTimeField
-------------------------------------+-------------------------------------
Reporter: Matthew Pava | Owner: Mads
| Jensen
Type: New feature | Status: assigned

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

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

* owner: nobody => Mads Jensen
* status: new => assigned
* has_patch: 0 => 1


Comment:

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

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

Django

unread,
Apr 20, 2017, 8:50:14 PM4/20/17
to django-...@googlegroups.com
#28103: Add "quarter" lookup to DateField/DateTimeField
-------------------------------------+-------------------------------------
Reporter: Matthew Pava | Owner: Mads
| Jensen
Type: New feature | Status: assigned
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: ORM Extract Trunc | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham):

* needs_better_patch: 0 => 1
* easy: 1 => 0


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

Django

unread,
Apr 22, 2017, 7:23:19 AM4/22/17
to django-...@googlegroups.com
#28103: Add "quarter" lookup to DateField/DateTimeField
-------------------------------------+-------------------------------------
Reporter: Matthew Pava | Owner: Mads
| Jensen
Type: New feature | Status: assigned
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: ORM Extract Trunc | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Mads Jensen):

Oracle and PostgreSQL have built-in functionality for truncating a date to
the first month of a quarter. However, in Oracle, it rounds up
(https://docs.oracle.com/database/121/SQLRF/functions271.htm#SQLRF52058)
and in PostgreSQL, it's always rounded down
(https://www.postgresql.org/docs/current/static/functions-datetime.html
#FUNCTIONS-DATETIME-TRUNC). Neither SQLite or MySQL has a convenient
built-in functionality and it's a matter of interpretation.

The Extract functionality is implemented, and has the same behavior on all
backends.

--
Ticket URL: <https://code.djangoproject.com/ticket/28103#comment:6>

Django

unread,
Apr 24, 2017, 2:38:13 AM4/24/17
to django-...@googlegroups.com
#28103: Add "quarter" lookup to DateField/DateTimeField
-------------------------------------+-------------------------------------
Reporter: Matthew Pava | Owner: Mads
| Jensen
Type: New feature | Status: assigned
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: ORM Extract Trunc | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

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

* needs_better_patch: 1 => 0


--
Ticket URL: <https://code.djangoproject.com/ticket/28103#comment:7>

Django

unread,
Jun 8, 2017, 3:15:41 PM6/8/17
to django-...@googlegroups.com
#28103: Add "quarter" lookup to DateField/DateTimeField
-------------------------------------+-------------------------------------
Reporter: Matthew Pava | Owner: Mads
| Jensen
Type: New feature | Status: closed

Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution: fixed
Keywords: ORM Extract Trunc | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham <timograham@…>):

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


Comment:

In [changeset:"c7f6ffbdcf9ca8df905aebf73336ef9905771f7c" c7f6ffbd]:
{{{
#!CommitTicketReference repository=""
revision="c7f6ffbdcf9ca8df905aebf73336ef9905771f7c"
Fixed #28103 -- Added quarter extract, truncation, and lookup.

Thanks Mariusz Felisiak, Tim Graham, and Adam Johnson for review.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/28103#comment:8>

Reply all
Reply to author
Forward
0 new messages