diff options
| author | Jacob Walls <jacobtylerwalls@gmail.com> | 2024-12-29 03:14:41 -0800 |
|---|---|---|
| committer | Sarah Boyce <42296566+sarahboyce@users.noreply.github.com> | 2025-01-03 08:40:13 +0100 |
| commit | c3a681659c4a982101ffee0d3ef205ac5b310e17 (patch) | |
| tree | 4cb75cc47d44b77b44baf405bc2b4d9b8b38504e /tests/filtered_relation | |
| parent | 45dc2aaa2a9dfe6d7d706f5e9f6757318423602e (diff) | |
Fixed #36029 -- Handled implicit exact lookups in condition depth checks for FilteredRelation.
Diffstat (limited to 'tests/filtered_relation')
| -rw-r--r-- | tests/filtered_relation/tests.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/filtered_relation/tests.py b/tests/filtered_relation/tests.py index 82caba8662..cbf77752df 100644 --- a/tests/filtered_relation/tests.py +++ b/tests/filtered_relation/tests.py @@ -668,6 +668,19 @@ class FilteredRelationTests(TestCase): ), ) + def test_condition_deeper_relation_name_implicit_exact(self): + msg = ( + "FilteredRelation's condition doesn't support nested relations " + "deeper than the relation_name (got 'book__editor__name' for 'book')." + ) + with self.assertRaisesMessage(ValueError, msg): + Author.objects.annotate( + book_editor=FilteredRelation( + "book", + condition=Q(book__editor__name="b"), + ), + ) + def test_with_empty_relation_name_error(self): with self.assertRaisesMessage(ValueError, "relation_name cannot be empty."): FilteredRelation("", condition=Q(blank="")) |
