Skip to content

Commit

Permalink
When we fork a query, make sure we create the new visualizations in t…
Browse files Browse the repository at this point in the history
…he same order as per the source query (#4067)
  • Loading branch information
Jakdaw authored and arikfr committed Aug 14, 2019
1 parent 934a145 commit d49514a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion redash/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down

0 comments on commit d49514a

Please sign in to comment.