diff --git a/django/db/models/query.py b/django/db/models/query.py index 1cacd9b59e..f30c8397bd 100644 --- a/django/db/models/query.py +++ b/django/db/models/query.py @@ -453,7 +453,7 @@ class QOperator: self.args = args def get_sql(self, opts): - tables, joins, where, params = [], {}, [], [] + tables, joins, where, params = [], SortedDict(), [], [] for val in self.args: tables2, joins2, where2, params2 = val.get_sql(opts) tables.extend(tables2)