mirror of
https://github.com/django/django.git
synced 2025-10-23 21:59:11 +00:00
Fixed #22023 -- Raised an error for values() followed by defer() or only().
Previously, doing so resulted in invalid data or crash. Thanks jtiai for the report and Karol Jochelson, Jakub Nowak, Loic Bistuer, and Baptiste Mispelon for reviews.
This commit is contained in:
committed by
Tim Graham
parent
a7639722f5
commit
faf6a911ad
@@ -1275,6 +1275,16 @@ class Queries3Tests(BaseQuerysetTest):
|
||||
Item.objects.datetimes, 'name', 'month'
|
||||
)
|
||||
|
||||
def test_ticket22023(self):
|
||||
# only() and defer() are not applicable for ValuesQuerySet
|
||||
with self.assertRaisesMessage(NotImplementedError,
|
||||
"ValuesQuerySet does not implement only()"):
|
||||
Valid.objects.values().only()
|
||||
|
||||
with self.assertRaisesMessage(NotImplementedError,
|
||||
"ValuesQuerySet does not implement defer()"):
|
||||
Valid.objects.values().defer()
|
||||
|
||||
|
||||
class Queries4Tests(BaseQuerysetTest):
|
||||
def setUp(self):
|
||||
|
||||
Reference in New Issue
Block a user