File tree Expand file tree Collapse file tree 2 files changed +22
-0
lines changed
Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -55,6 +55,10 @@ def rename_annotations(self, annotations) -> None:
5555 self .annotations [new_name ] = annotation
5656 del self .annotations [old_name ]
5757
58+ if self .annotation_select_mask :
59+ self .annotation_select_mask .discard (old_name )
60+ self .annotation_select_mask .add (new_name )
61+
5862 def add_fields (self , field_names : List [str ], * args , ** kwargs ) -> bool :
5963 """Adds the given (model) fields to the select set.
6064
Original file line number Diff line number Diff line change @@ -43,6 +43,24 @@ def test_query_annotate_rename():
4343 assert obj .title == "swen"
4444
4545
46+ def test_query_annotate_rename_chain ():
47+ """Tests whether annotations are behaving correctly after a QuerySet
48+ chain."""
49+
50+ model = get_fake_model (
51+ {
52+ "name" : models .CharField (max_length = 10 ),
53+ "value" : models .IntegerField (),
54+ }
55+ )
56+
57+ model .objects .create (name = "test" , value = 23 )
58+
59+ obj = model .objects .values ("name" ).annotate (value = F ("value" ))[:1 ]
60+ assert "value" in obj [0 ]
61+ assert obj [0 ]["value" ] == 23
62+
63+
4664def test_query_hstore_value_update_f_ref ():
4765 """Tests whether F(..) expressions can be used in hstore values when
4866 performing update queries."""
You can’t perform that action at this time.
0 commit comments