mirror of
https://github.com/django/django.git
synced 2025-08-03 10:34:04 +00:00
Fixed #27544 -- Fixed QuerySet.update(dt=F('dt') + timedelta) crash on SQLite.
This commit is contained in:
parent
fb3716b156
commit
ade52ef71f
3 changed files with 14 additions and 2 deletions
|
@ -14,7 +14,7 @@ from django.contrib.auth.models import User
|
|||
from django.core import serializers
|
||||
from django.core.exceptions import ImproperlyConfigured
|
||||
from django.db import connection, connections
|
||||
from django.db.models import Max, Min
|
||||
from django.db.models import F, Max, Min
|
||||
from django.http import HttpRequest
|
||||
from django.template import (
|
||||
Context, RequestContext, Template, TemplateSyntaxError, context_processors,
|
||||
|
@ -26,6 +26,7 @@ from django.test import (
|
|||
from django.test.utils import requires_tz_support
|
||||
from django.urls import reverse
|
||||
from django.utils import six, timezone
|
||||
from django.utils.timezone import timedelta
|
||||
|
||||
from .forms import (
|
||||
EventForm, EventLocalizedForm, EventLocalizedModelForm, EventModelForm,
|
||||
|
@ -569,6 +570,13 @@ class NewDatabaseTests(TestCase):
|
|||
e = MaybeEvent.objects.create()
|
||||
self.assertIsNone(e.dt)
|
||||
|
||||
def test_update_with_timedelta(self):
|
||||
initial_dt = timezone.now().replace(microsecond=0)
|
||||
event = Event.objects.create(dt=initial_dt)
|
||||
Event.objects.update(dt=F('dt') + timedelta(hours=2))
|
||||
event.refresh_from_db()
|
||||
self.assertEqual(event.dt, initial_dt + timedelta(hours=2))
|
||||
|
||||
|
||||
@override_settings(TIME_ZONE='Africa/Nairobi', USE_TZ=True)
|
||||
class ForcedTimeZoneDatabaseTests(TransactionTestCase):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue