I'm assuming something like this:
{{{
class Today(Func):
template = "CURRENT_DATE"
output_field = DateField()
def as_postgresql(self, compiler, connection, **extra_context):
# PostgreSQL's CURRENT_TIMESTAMP means "the time at the start of
the
# transaction". Use STATEMENT_TIMESTAMP to be cross-compatible
with
# other databases.
return self.as_sql(
compiler, connection, template="STATEMENT_TIMESTAMP()",
**extra_context
)
def as_mysql(self, compiler, connection, **extra_context):
return self.as_sql(
compiler, connection, template="CURRENT_DATE()",
**extra_context
)
def as_sqlite(self, compiler, connection, **extra_context):
return self.as_sql(
compiler,
connection,
template="STRFTIME('%%%%Y-%%%%m-%%%%d', 'NOW')",
**extra_context,
)
}}}
What do you think about?
--
Ticket URL: <https://code.djangoproject.com/ticket/34364>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.