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.
* version: 1.8 => master
* stage: Unreviewed => Accepted
--
Ticket URL: <https://code.djangoproject.com/ticket/24866#comment:1>
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>
* owner: nobody => adamchainz
* status: new => assigned
--
Ticket URL: <https://code.djangoproject.com/ticket/24866#comment:3>
Comment (by adamchainz):
Pull request: https://github.com/django/django/pull/4722
--
Ticket URL: <https://code.djangoproject.com/ticket/24866#comment:4>
* needs_docs: 1 => 0
* has_patch: 0 => 1
* needs_tests: 1 => 0
--
Ticket URL: <https://code.djangoproject.com/ticket/24866#comment:5>
* stage: Accepted => Ready for checkin
--
Ticket URL: <https://code.djangoproject.com/ticket/24866#comment:6>
* 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>