[Django] #24866: Add CURRENT_TIMESTAMP function to db.functions

26 views
Skip to first unread message

Django

unread,
May 27, 2015, 8:30:53 PM5/27/15
to django-...@googlegroups.com
#24866: Add CURRENT_TIMESTAMP function to db.functions
-------------------------------------+-------------------------------------
Reporter: funkybob | Owner: nobody
Type: New | Status: new
feature |
Component: Database | Version: 1.8
layer (models, ORM) |
Severity: Normal | Keywords:
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 1 | Needs tests: 1
Patch needs improvement: 0 | Easy pickings: 1
UI/UX: 0 |
-------------------------------------+-------------------------------------
00:21 <+jarshwah> or.. Func(template='NOW()',
output_field=DateTimeFIeld()) would work too


Postgres, MySQL, SQLite and MS SQL support this function, and it would be
very handy.

In the past I've implemented it using an ExpressionNode, but with the new
functions module, it could be simpler and more useful.

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

Django

unread,
May 27, 2015, 8:37:39 PM5/27/15
to django-...@googlegroups.com
#24866: Add CURRENT_TIMESTAMP function to db.functions
-------------------------------------+-------------------------------------
Reporter: funkybob | Owner: nobody
Type: New feature | Status: new
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 1

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

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


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

Django

unread,
May 27, 2015, 8:41:54 PM5/27/15
to django-...@googlegroups.com
#24866: Add CURRENT_TIMESTAMP function to db.functions
-------------------------------------+-------------------------------------
Reporter: funkybob | Owner: nobody
Type: New feature | Status: new
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 1

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

Comment (by jarshwah):

Below is probably the way to go. We haven't done 0-arity Func expressions
before though, so there may be some hidden traps waiting. It'd go in
django.db.models.functions.py

{{{
class Now(Func):
template = 'CURRENT_TIMESTAMP()'
def __init__(self, output_field=DateTimeField(), **extra):
super(Func, self).__init__(output_field=output_field, **extra)
}}}

This should (famous last words) be a relatively straight forward patch.
I'd encourage someone that wants to get some basic familiarity with the
ORM and expressions in general to have a go at implementing.

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

Django

unread,
May 29, 2015, 10:52:20 AM5/29/15
to django-...@googlegroups.com
#24866: Add CURRENT_TIMESTAMP function to db.functions
-------------------------------------+-------------------------------------
Reporter: funkybob | Owner:
| adamchainz
Type: New feature | Status: assigned

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

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

* owner: nobody => adamchainz
* status: new => assigned


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

Django

unread,
May 29, 2015, 11:05:26 AM5/29/15
to django-...@googlegroups.com
#24866: Add CURRENT_TIMESTAMP function to db.functions
-------------------------------------+-------------------------------------
Reporter: funkybob | Owner:
| adamchainz
Type: New feature | Status: assigned
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 1

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

Comment (by adamchainz):

Pull request: https://github.com/django/django/pull/4722

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

Django

unread,
May 29, 2015, 1:20:25 PM5/29/15
to django-...@googlegroups.com
#24866: Add CURRENT_TIMESTAMP function to db.functions
-------------------------------------+-------------------------------------
Reporter: funkybob | Owner:
| adamchainz
Type: New feature | Status: assigned
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by timgraham):

* needs_docs: 1 => 0
* has_patch: 0 => 1
* needs_tests: 1 => 0


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

Django

unread,
Jun 2, 2015, 10:46:48 AM6/2/15
to django-...@googlegroups.com
#24866: Add CURRENT_TIMESTAMP function to db.functions
-------------------------------------+-------------------------------------
Reporter: funkybob | Owner:
| adamchainz
Type: New feature | Status: assigned
Component: Database layer | Version: master
(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 timgraham):

* stage: Accepted => Ready for checkin


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

Django

unread,
Jun 2, 2015, 5:59:22 PM6/2/15
to django-...@googlegroups.com
#24866: Add CURRENT_TIMESTAMP function to db.functions
-------------------------------------+-------------------------------------
Reporter: funkybob | Owner:
| adamchainz
Type: New feature | Status: closed

Component: Database layer | Version: master
(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 Tim Graham <timograham@…>):

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


Comment:

In [changeset:"23048d186ce0041654a9f547fe3e7177efce3076" 23048d18]:
{{{
#!CommitTicketReference repository=""
revision="23048d186ce0041654a9f547fe3e7177efce3076"
Fixed #24866 -- Added Now() database function
}}}

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

Reply all
Reply to author
Forward
0 new messages