summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorVytis Banaitis <vytis.banaitis@gmail.com>2017-02-12 16:43:04 +0200
committerTim Graham <timograham@gmail.com>2017-02-16 17:24:05 -0500
commit75327b88a829e2c4be1775b24e0cf6349b26ace4 (patch)
tree6d9a57ffaf1cefb25c21b0f2c10843df8a896c31 /tests
parent4d9143d029bc6eb826fdd0d2062386ac4c7e5519 (diff)
[1.10.x] Fixed #27828 -- Fixed a crash when subtracting Integer/DurationField from DateField on Oracle/PostgreSQL.
Thanks Mariusz Felisiak for the Oracle workaround. Backport of d5088f838d837fc9e3109c828f18511055f20bea from master
Diffstat (limited to 'tests')
-rw-r--r--tests/expressions/tests.py11
1 files changed, 10 insertions, 1 deletions
diff --git a/tests/expressions/tests.py b/tests/expressions/tests.py
index 27929c9146..b1b07393b0 100644
--- a/tests/expressions/tests.py
+++ b/tests/expressions/tests.py
@@ -15,7 +15,7 @@ from django.db.models.expressions import (
When,
)
from django.db.models.functions import (
- Coalesce, Concat, Length, Lower, Substr, Upper,
+ Cast, Coalesce, Concat, Length, Lower, Substr, Upper,
)
from django.test import TestCase, skipIfDBFeature, skipUnlessDBFeature
from django.test.utils import Approximate
@@ -908,6 +908,15 @@ class FTimeDeltaTests(TestCase):
).order_by('name')
self.assertQuerysetEqual(over_estimate, ['e3', 'e4'], lambda e: e.name)
+ def test_date_minus_duration(self):
+ value = (
+ Cast(Value(datetime.timedelta(days=4)), models.DurationField())
+ if connection.vendor == 'oracle'
+ else Value(datetime.timedelta(days=4), output_field=models.DurationField())
+ )
+ more_than_4_days = Experiment.objects.filter(assigned__lt=F('completed') - value)
+ self.assertQuerysetEqual(more_than_4_days, ['e3', 'e4'], lambda e: e.name)
+
class ValueTests(TestCase):
def test_update_TimeField_using_Value(self):