mirror of
https://github.com/django/django.git
synced 2025-10-30 00:56:09 +00:00
Fixed #27332 -- Added FilteredRelation API for conditional join (ON clause) support.
Thanks Anssi Kääriäinen for contributing to the patch.
This commit is contained in:
committed by
Tim Graham
parent
3f9d85d95c
commit
01d440fa1e
@@ -1,4 +1,5 @@
|
||||
from django.core.exceptions import FieldError
|
||||
from django.db.models import FilteredRelation
|
||||
from django.test import SimpleTestCase, TestCase
|
||||
|
||||
from .models import (
|
||||
@@ -230,3 +231,8 @@ class ReverseSelectRelatedValidationTests(SimpleTestCase):
|
||||
|
||||
with self.assertRaisesMessage(FieldError, self.non_relational_error % ('username', fields)):
|
||||
list(User.objects.select_related('username'))
|
||||
|
||||
def test_reverse_related_validation_with_filtered_relation(self):
|
||||
fields = 'userprofile, userstat, relation'
|
||||
with self.assertRaisesMessage(FieldError, self.invalid_error % ('foobar', fields)):
|
||||
list(User.objects.annotate(relation=FilteredRelation('userprofile')).select_related('foobar'))
|
||||
|
||||
Reference in New Issue
Block a user