-
Notifications
You must be signed in to change notification settings - Fork 13.5k
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
fix(filters): Stop breaking if translateToSql returns an object #23715
fix(filters): Stop breaking if translateToSql returns an object #23715
Conversation
@@ -135,6 +135,10 @@ export default class AdhocFilter { | |||
|
|||
getDefaultLabel() { | |||
const label = this.translateToSql(); | |||
// If returned value is an object after changing dataset | |||
if (typeof label === 'object') { | |||
return label.column_name ?? ''; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do I understand correctly that the bug occurs when adhocFIlter.subject
is an object and not a string? If so, maybe we could move the logic of extracting column_name to getSimpleSQLExpression
, line 298 - let expression = subject ?? '';
?
2415af7
to
699870a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lgtm
Codecov Report
@@ Coverage Diff @@
## master #23715 +/- ##
=======================================
Coverage 68.18% 68.19%
=======================================
Files 1941 1941
Lines 75241 75242 +1
Branches 8158 8157 -1
=======================================
+ Hits 51306 51308 +2
+ Misses 21852 21851 -1
Partials 2083 2083
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 1 file with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
SUMMARY
There might be times where after changing the dataset, the
translateToSql
is not just a string but an object and thus you get an error when trying to perform the substring operation. In that case we need to get the label from thecolumn_name
if present if not just return an empty string instead.BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
Before:
![error](https://user-images.githubusercontent.com/38889534/232602461-2b3fef28-44a2-49a1-ac2d-01bed6bce8b3.png)
After:
![test](https://user-images.githubusercontent.com/38889534/232603574-d13dd959-27fb-4dad-87a1-ae1ab5229439.gif)
TESTING INSTRUCTIONS
ADDITIONAL INFORMATION