From 0b71baed9a27ef0df99dd0fa83e5f80ad824d9f0 Mon Sep 17 00:00:00 2001 From: Jakdaw Date: Wed, 14 Aug 2019 09:08:56 +0100 Subject: [PATCH] When we fork a query, make sure we create the new visualizations in the same order as per the source query (#4067) --- redash/models/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/redash/models/__init__.py b/redash/models/__init__.py index 9ca29bdc36..a4671e5824 100644 --- a/redash/models/__init__.py +++ b/redash/models/__init__.py @@ -648,7 +648,7 @@ def fork(self, user): # Query.create will add default TABLE visualization, so use constructor to create bare copy of query forked_query = Query(name=u'Copy of (#{}) {}'.format(self.id, self.name), user=user, **kwargs) - for v in self.visualizations: + for v in sorted(self.visualizations, key=lambda v: v.id): forked_v = v.copy() forked_v['query_rel'] = forked_query fv = Visualization(**forked_v) # it will magically add it to `forked_query.visualizations`