mirror of
https://github.com/django/django.git
synced 2025-11-25 05:04:26 +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:
parent
a7639722f5
commit
faf6a911ad
4 changed files with 34 additions and 3 deletions
|
|
@ -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):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue