mirror of
https://github.com/django/django.git
synced 2025-08-04 10:59:45 +00:00
Fixed null handling in Value expression
This commit is contained in:
parent
1f03d2d924
commit
8713ea7568
3 changed files with 26 additions and 1 deletions
|
@ -5,7 +5,7 @@ import datetime
|
|||
|
||||
from django.core.exceptions import FieldError
|
||||
from django.db import connection, transaction, DatabaseError
|
||||
from django.db.models import F
|
||||
from django.db.models import F, Value
|
||||
from django.test import TestCase, skipIfDBFeature, skipUnlessDBFeature
|
||||
from django.test.utils import Approximate
|
||||
from django.utils import six
|
||||
|
@ -174,6 +174,19 @@ class BasicExpressionsTests(TestCase):
|
|||
ordered=False
|
||||
)
|
||||
|
||||
def test_update_with_none(self):
|
||||
Number.objects.create(integer=1, float=1.0)
|
||||
Number.objects.create(integer=2)
|
||||
Number.objects.filter(float__isnull=False).update(float=Value(None))
|
||||
self.assertQuerysetEqual(
|
||||
Number.objects.all(), [
|
||||
None,
|
||||
None,
|
||||
],
|
||||
lambda n: n.float,
|
||||
ordered=False
|
||||
)
|
||||
|
||||
def test_filter_with_join(self):
|
||||
# F Expressions can also span joins
|
||||
Company.objects.update(point_of_contact=F('ceo'))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue