mirror of
https://github.com/django/django.git
synced 2025-12-04 00:55:36 +00:00
Refs #10929 -- Allowed NowUTC SQL customization for third-party backends.
This commit is contained in:
parent
ed317e79e3
commit
022d29c934
5 changed files with 10 additions and 8 deletions
|
|
@ -26,14 +26,10 @@ class NowUTC(Now):
|
|||
template = 'CURRENT_TIMESTAMP'
|
||||
output_field = DateTimeField()
|
||||
|
||||
def as_mysql(self, compiler, connection, **extra_context):
|
||||
return self.as_sql(compiler, connection, template='UTC_TIMESTAMP', **extra_context)
|
||||
|
||||
def as_oracle(self, compiler, connection, **extra_context):
|
||||
return self.as_sql(compiler, connection, template="CURRENT_TIMESTAMP AT TIME ZONE 'UTC'", **extra_context)
|
||||
|
||||
def as_postgresql(self, compiler, connection, **extra_context):
|
||||
return self.as_sql(compiler, connection, template="STATEMENT_TIMESTAMP() AT TIME ZONE 'UTC'", **extra_context)
|
||||
def as_sql(self, compiler, connection, **extra_context):
|
||||
if connection.features.test_now_utc_template:
|
||||
extra_context['template'] = connection.features.test_now_utc_template
|
||||
return super().as_sql(compiler, connection, **extra_context)
|
||||
|
||||
|
||||
class AggregateTestCase(TestCase):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue