[rqlrewrite] sort possible types when turning is_instance_of into is
authorJulien Cristau <julien.cristau@logilab.fr>
Fri, 13 Feb 2015 11:48:13 +0100
changeset 10249 e38b8d37c5d8
parent 10248 131275d6c268
child 10250 582301c2c8ca
[rqlrewrite] sort possible types when turning is_instance_of into is Helps get predictable output even with python -R. Related to #4959402.
rqlrewrite.py
server/test/unittest_security.py
--- a/rqlrewrite.py	Fri Feb 13 11:47:34 2015 +0100
+++ b/rqlrewrite.py	Fri Feb 13 11:48:13 2015 +0100
@@ -89,7 +89,7 @@
                 mytyperel.r_type = 'is'
                 if len(possibletypes) > 1:
                     node = n.Function('IN')
-                    for etype in possibletypes:
+                    for etype in sorted(possibletypes):
                         node.append(n.Constant(etype, 'etype'))
                 else:
                     etype = iter(possibletypes).next()
--- a/server/test/unittest_security.py	Fri Feb 13 11:47:34 2015 +0100
+++ b/server/test/unittest_security.py	Fri Feb 13 11:48:13 2015 +0100
@@ -519,7 +519,7 @@
                 plan.preprocess(rqlst)
                 self.assertEqual(
                     rqlst.as_string(),
-                    '(Any X WHERE X is IN(SubDivision, Societe)) UNION '
+                    '(Any X WHERE X is IN(Societe, SubDivision)) UNION '
                     '(Any X WHERE X is Division, EXISTS(X owned_by %(B)s))')