Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

don't autoexecute query on changing datasource #2652

Closed
wants to merge 2 commits into from

Conversation

alison985
Copy link
Contributor

fixes #2651

This is a port of a Mozilla feature upstream.

Copy link
Member

@arikfr arikfr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's a good idea, but my only concern is that if we leave previous results it might be confusing.

Maybe we should remove previous results when switching data sources?

@alison985
Copy link
Contributor Author

That makes sense to me Arik. I'm assuming you mean just hide the display of the results from the UI.

There is already a ng-if="showDataset" in the query.html page for the tabs and data of query results. I tried adding $scope.showDataset = false; locally and adding a setter for showDataset to fix this error: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Getter_only but that didn't work so I added a new variable.

@arikfr
Copy link
Member

arikfr commented Jul 8, 2018

That makes sense to me Arik. I'm assuming you mean just hide the display of the results from the UI.

No, actually the important thing is to clear the reference to the last result (latest_query_data_id). Because otherwise someone loading this query will see that it uses some data source that the results don't belong to.

@alison985
Copy link
Contributor Author

@alison985
Copy link
Contributor Author

@arikfr Do I need to do anything else before this can be merged?

@jezdez
Copy link
Member

jezdez commented Aug 14, 2018

@alison985 Let's wait till Arik is back for this to merge.

@jezdez jezdez self-requested a review September 7, 2018 19:19
Copy link
Member

@jezdez jezdez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be written with a boolean state that describes if the datasource has changed, as a $scope.dataSourceChanged.

Additionally, I think we'll need to set $scope.dataSourceChanged when the query is executed manually to reset the result/viz div.

@@ -120,6 +120,7 @@ function QueryViewCtrl(
Notifications.getPermissions();
};

$scope.dataSourceHasNotChanged = true;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's turn around the logic and call this dataSourceChanged with a default of false so we don't have to deal with a double negative below.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jezdez Updated.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alison985 Thank you! 😃

@alison985
Copy link
Contributor Author

@jezdez Ready for Review.

Copy link
Member

@jezdez jezdez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor issue with inline styles, LGTM otherwise.

@@ -217,7 +217,9 @@ <h3>
<!-- End of Query Execution Status -->

<!-- tabs and data -->
<div ng-if="showDataset" class="flex-fill p-relative">
<div ng-if="showDataset && dataSourceChanged" class="flex-fill p-relative">
<div class="d-flex flex-column p-absolute" style="left: 0; top: 0; right: 0; bottom: 0;">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This opens a new div without closing it, and also uses inline styles. Is this needed or just for debugging purposes?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These lines actually look like the result of a bad merge as they serve no purpose. I've removed them. The in-line styles below were there before me.

@@ -217,7 +217,7 @@ <h3>
<!-- End of Query Execution Status -->

<!-- tabs and data -->
<div ng-if="showDataset" class="flex-fill p-relative">
<div ng-if="showDataset && dataSourceChanged" class="flex-fill p-relative">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So... it will show the data set if the data source was changed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@arikfr This variable was originally dataSourceHasNotChanged but @jezdez wanted to remove the double negative. This is the variable added to handle your comments above to not show results when the datasource has changed. You're right to question this, I will add the ! now.

@alison985
Copy link
Contributor Author

Ping @jezdez and @arikfr

@alison985
Copy link
Contributor Author

Docker Hub issue made build fail. When Docker Hub is back up the build should be rerun.

@alison985
Copy link
Contributor Author

Anything else on this one @jezdez and/or @arikfr?

@jezdez jezdez self-assigned this Jan 23, 2019
@chang
Copy link
Contributor

chang commented Feb 13, 2019

+1 This could be especially dangerous when developing a mutation query on a test database. If the schemas are similar enough, it could successfully and unintentionally auto-execute while switching over to a prod data source.

Copy link
Member

@arikfr arikfr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I understand it correctly, dataSourceChanged is needed only in view. But in view mode, you can't change the data source...

@arikfr
Copy link
Member

arikfr commented Jan 21, 2020

Hi,

(This is a template message, but I mean every word of it. Also you're welcome to reply)

Thank you for making this contribution. While we couldn't bring it to completion and merge, it's still very much appreciated. 🙇

In the past year the Redash code base gone under massive updates: on the backend we moved to Python 3 & RQ instead of Celery and on the frontend we replaced Angular with React. It's very likely this makes this PR irrelevant without significant changes. :-(

I'm closing this PR now. But if you're still interested in making it happen, let me know and I will reopen.

Thanks.

@arikfr arikfr closed this Jan 21, 2020
@jezdez
Copy link
Member

jezdez commented Jan 22, 2020

@arikfr I'm a bit confused by your last review comment, you're right that changing the source is only possible in edit mode, but I still see a request happening against the server when the source is changed there, and I believe the query is actually executed. I'd appreciate if you'd double-check this on your side so we can close this.

Here's a screen recording of the current master executing the query when changing a data source (if it's the same type of data source): https://dsc.cloud/a46d84/RhVthKiRVrg1Od79fBzY

@arikfr
Copy link
Member

arikfr commented Jan 22, 2020

I just tried it out on https://redash-preview.netlify.com/ and couldn't reproduce it. And looking at your video again I can see that it's definitely not the latest master. Maybe you didn't rebuild the assets?

@jezdez
Copy link
Member

jezdez commented Jan 23, 2020

Lemme check again, thanks!

@jezdez
Copy link
Member

jezdez commented Jan 23, 2020

You right, @arikfr, that was it :) Sorry for the noise!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Don't execute auto-execute query when changing datasources
5 participants