mirror of
https://github.com/django/django.git
synced 2025-10-31 09:41:08 +00:00
Fixed #34070 -- Added subsecond support to Now() on SQLite and MySQL.
This commit is contained in:
committed by
Mariusz Felisiak
parent
f71b0cf769
commit
649b28eab6
@@ -81,7 +81,7 @@ class DatabaseFeatures(BaseDatabaseFeatures):
|
||||
"swedish_ci": f"{charset}_swedish_ci",
|
||||
}
|
||||
|
||||
test_now_utc_template = "UTC_TIMESTAMP"
|
||||
test_now_utc_template = "UTC_TIMESTAMP(6)"
|
||||
|
||||
@cached_property
|
||||
def django_test_skips(self):
|
||||
|
||||
@@ -223,6 +223,19 @@ class Now(Func):
|
||||
compiler, connection, template="STATEMENT_TIMESTAMP()", **extra_context
|
||||
)
|
||||
|
||||
def as_mysql(self, compiler, connection, **extra_context):
|
||||
return self.as_sql(
|
||||
compiler, connection, template="CURRENT_TIMESTAMP(6)", **extra_context
|
||||
)
|
||||
|
||||
def as_sqlite(self, compiler, connection, **extra_context):
|
||||
return self.as_sql(
|
||||
compiler,
|
||||
connection,
|
||||
template="STRFTIME('%%Y-%%m-%%d %%H:%%M:%%f', 'NOW')",
|
||||
**extra_context,
|
||||
)
|
||||
|
||||
|
||||
class TruncBase(TimezoneMixin, Transform):
|
||||
kind = None
|
||||
|
||||
Reference in New Issue
Block a user