Fixed #30988 -- Deprecated the InvalidQuery exception.

It was barely documented without pointers at its defining location and
was abused to prevent misuse of the QuerySet field deferring feature.
This commit is contained in:
Simon Charette 2019-11-15 16:20:07 -05:00 committed by Mariusz Felisiak
parent cbe4d6203f
commit 11e327a3ff
8 changed files with 82 additions and 15 deletions

View file

@ -1,8 +1,8 @@
from datetime import date
from decimal import Decimal
from django.core.exceptions import FieldDoesNotExist
from django.db.models.query import RawQuerySet
from django.db.models.query_utils import InvalidQuery
from django.test import TestCase, skipUnlessDBFeature
from .models import (
@ -235,7 +235,8 @@ class RawQueryTests(TestCase):
def test_missing_fields_without_PK(self):
query = "SELECT first_name, dob FROM raw_query_author"
with self.assertRaisesMessage(InvalidQuery, 'Raw query must include the primary key'):
msg = 'Raw query must include the primary key'
with self.assertRaisesMessage(FieldDoesNotExist, msg):
list(Author.objects.raw(query))
def test_annotations(self):