mirror of
https://github.com/django/django.git
synced 2025-11-20 03:30:00 +00:00
Fixed #36480 -- Made values() resolving error mention unselected aliases.
Follow-up to cb13792938. Refs #34437.
This commit is contained in:
parent
af84cfba59
commit
dce1b9c2de
2 changed files with 11 additions and 1 deletions
|
|
@ -1817,7 +1817,7 @@ class Query(BaseExpression):
|
|||
available = sorted(
|
||||
[
|
||||
*get_field_names_from_opts(opts),
|
||||
*self.annotation_select,
|
||||
*self.annotations,
|
||||
*self._filtered_relations,
|
||||
]
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1539,3 +1539,13 @@ class AliasTests(TestCase):
|
|||
)
|
||||
with self.assertRaisesMessage(ValueError, msg):
|
||||
Book.objects.alias(**{crafted_alias: FilteredRelation("authors")})
|
||||
|
||||
def test_values_wrong_alias(self):
|
||||
expected_message = (
|
||||
"Cannot resolve keyword 'alias_typo' into field. Choices are: %s"
|
||||
)
|
||||
alias_fields = ", ".join(
|
||||
sorted(["my_alias"] + list(get_field_names_from_opts(Book._meta)))
|
||||
)
|
||||
with self.assertRaisesMessage(FieldError, expected_message % alias_fields):
|
||||
Book.objects.alias(my_alias=F("pk")).order_by("alias_typo")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue