do not sort projections alphabetically (#23649)

* do not sort projections alphabetically
* add assertion for ordered dict
This commit is contained in:
Greg Becker 2021-05-15 09:19:10 -07:00 committed by GitHub
parent 2a7fa295fb
commit 2202ce27fa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -9,6 +9,7 @@
import shutil
import copy
import six
import ruamel.yaml as yaml
from ordereddict_backport import OrderedDict
@ -478,9 +479,12 @@ def __eq__(self, other):
def to_dict(self):
ret = syaml.syaml_dict([('root', self.root)])
if self.projections:
projections_dict = syaml.syaml_dict(
sorted(self.projections.items()))
ret['projections'] = projections_dict
# projections guaranteed to be ordered dict if true-ish
# for python2.6, may be syaml or ruamel.yaml implementation
# so we have to check for both
types = (OrderedDict, syaml.syaml_dict, yaml.comments.CommentedMap)
assert isinstance(self.projections, types)
ret['projections'] = self.projections
if self.select:
ret['select'] = self.select
if self.exclude: