Fixed #28934 -- Prevented Cast from truncating microseconds on Oracle.
This commit is contained in:
parent
a7a36bb4d8
commit
fc9eec7bb7
|
@ -350,6 +350,8 @@ class OracleParam:
|
||||||
elif string_size > 4000:
|
elif string_size > 4000:
|
||||||
# Mark any string param greater than 4000 characters as a CLOB.
|
# Mark any string param greater than 4000 characters as a CLOB.
|
||||||
self.input_size = Database.CLOB
|
self.input_size = Database.CLOB
|
||||||
|
elif isinstance(param, datetime.datetime):
|
||||||
|
self.input_size = Database.TIMESTAMP
|
||||||
else:
|
else:
|
||||||
self.input_size = None
|
self.input_size = None
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import datetime
|
import datetime
|
||||||
|
|
||||||
from django.db import connection, models
|
from django.db import models
|
||||||
from django.db.models.expressions import Value
|
from django.db.models.expressions import Value
|
||||||
from django.db.models.functions import Cast
|
from django.db.models.functions import Cast
|
||||||
from django.test import TestCase, ignore_warnings, skipUnlessDBFeature
|
from django.test import TestCase, ignore_warnings, skipUnlessDBFeature
|
||||||
|
@ -51,9 +51,6 @@ class CastTests(TestCase):
|
||||||
|
|
||||||
def test_cast_from_python_to_datetime(self):
|
def test_cast_from_python_to_datetime(self):
|
||||||
now = datetime.datetime.now()
|
now = datetime.datetime.now()
|
||||||
if connection.vendor == 'oracle':
|
|
||||||
# Workaround until #28934 is fixed.
|
|
||||||
now = now.replace(microsecond=0)
|
|
||||||
dates = Author.objects.annotate(cast_datetime=Cast(now, models.DateTimeField()))
|
dates = Author.objects.annotate(cast_datetime=Cast(now, models.DateTimeField()))
|
||||||
self.assertEqual(dates.get().cast_datetime, now)
|
self.assertEqual(dates.get().cast_datetime, now)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue