Skip to content

Commit

Permalink
Use OrderedDict for renamed annotations
Browse files Browse the repository at this point in the history
It works fine with a dict() because since Python 3.5, dicts
are ordered. However, that's an implementation detail and
we shouldn't rely on that.
  • Loading branch information
Photonios committed Oct 30, 2020
1 parent 94faf44 commit c11dbb5
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion psqlextra/sql.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from collections import OrderedDict
from typing import List, Optional, Tuple

import django
Expand Down Expand Up @@ -54,7 +55,7 @@ def rename_annotations(self, annotations) -> None:
)

# rebuild the annotations according to the original order
new_annotations = dict()
new_annotations = OrderedDict()
for old_name, annotation in self.annotations.items():
new_name = annotations.get(old_name)
new_annotations[new_name or old_name] = annotation
Expand Down

0 comments on commit c11dbb5

Please sign in to comment.