mirror of https://github.com/django/django.git
Fixed #27268 -- Restored an invalid related field lookup error message in QuerySet filtering.
This commit is contained in:
parent
602bffe758
commit
14986a0b9d
|
@ -1192,6 +1192,8 @@ class Query(object):
|
|||
raise FieldError('Related Field got invalid lookup: {}'.format(lookups[0]))
|
||||
assert num_lookups > 0 # Likely a bug in Django if this fails.
|
||||
lookup_class = field.get_lookup(lookups[0])
|
||||
if lookup_class is None:
|
||||
raise FieldError('Related Field got invalid lookup: {}'.format(lookups[0]))
|
||||
if len(targets) == 1:
|
||||
lhs = targets[0].get_col(alias, field)
|
||||
else:
|
||||
|
|
|
@ -515,6 +515,9 @@ class LookupTests(TestCase):
|
|||
msg = 'Related Field got invalid lookup: editor'
|
||||
with self.assertRaisesMessage(FieldError, msg):
|
||||
Article.objects.filter(author__editor__name='James')
|
||||
msg = 'Related Field got invalid lookup: foo'
|
||||
with self.assertRaisesMessage(FieldError, msg):
|
||||
Tag.objects.filter(articles__foo='bar')
|
||||
|
||||
def test_regex(self):
|
||||
# Create some articles with a bit more interesting headlines for testing field lookups:
|
||||
|
|
Loading…
Reference in New Issue