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

[Bugfix] Allowing sqlExpression to be blank #4991

Merged

Conversation

michellethomas
Copy link
Contributor

If you remove the sql in the custom sql filter, you'll see a message null undefined null. adhocFilter.sqlExpression || translateToSql(adhocFilter, { useSimple: true }) was running translateToSql with simple: true on an empty string. Change it to specifically check for undefined.

@GabeLoins

@@ -45,7 +45,8 @@ export default class AdhocFilter {
this.clause = adhocFilter.clause;
this.sqlExpression = null;
} else if (this.expressionType === EXPRESSION_TYPES.SQL) {
this.sqlExpression = adhocFilter.sqlExpression ||
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure in what cases this would have been undefined if expressionType === sql. Gabe do you have more context here? Is checking for undefined sufficient or do I also need to check for nulls?

@@ -45,7 +45,8 @@ export default class AdhocFilter {
this.clause = adhocFilter.clause;
this.sqlExpression = null;
Copy link
Contributor

Choose a reason for hiding this comment

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

sqlExpression can be set to null here, so you can't predict whether it will be undefined or null

@@ -45,7 +45,8 @@ export default class AdhocFilter {
this.clause = adhocFilter.clause;
this.sqlExpression = null;
} else if (this.expressionType === EXPRESSION_TYPES.SQL) {
this.sqlExpression = adhocFilter.sqlExpression ||
this.sqlExpression = typeof adhocFilter.sqlExpression !== 'undefined' ?
adhocFilter.sqlExpression :
translateToSql(adhocFilter, { useSimple: true });
Copy link
Contributor

Choose a reason for hiding this comment

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

what if you just removed the useSimple parameter? that might be the problem 🤔

@codecov-io
Copy link

codecov-io commented May 11, 2018

Codecov Report

Merging #4991 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@          Coverage Diff           @@
##           master   #4991   +/-   ##
======================================
  Coverage    77.1%   77.1%           
======================================
  Files          44      44           
  Lines        8636    8636           
======================================
  Hits         6659    6659           
  Misses       1977    1977

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7d5195a...ad4912d. Read the comment docs.

@michellethomas
Copy link
Contributor Author

michellethomas commented May 11, 2018

Like we discussed, I changed this to explicitly check if sqlExpression a string.

{ useSimple: true } is needed because if a metric filter is automatically added as expressionType SQL (in AdhocFilterControl) so when creating the AdhocFilter we need to check to make sure it is actually sql (with an expression).

@gabe-lyons
Copy link
Contributor

LGTM

@timifasubaa timifasubaa merged commit 071c6a6 into apache:master May 14, 2018
wenchma pushed a commit to wenchma/incubator-superset that referenced this pull request Nov 16, 2018
…ustom_sql

[Bugfix] Allowing sqlExpression to be blank
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.

None yet

4 participants