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

fixing boolean filters #15927

Merged
merged 3 commits into from
Jan 12, 2018
Merged

fixing boolean filters #15927

merged 3 commits into from
Jan 12, 2018

Conversation

ppisljar
Copy link
Member

@ppisljar ppisljar commented Jan 9, 2018

resolves #15114

release notes: filtering on boolean fields works again

@ppisljar ppisljar added review Feature:Visualizations Generic visualization features (in case no more specific feature label is available) release_note:fix v7.0.0 v6.2.0 labels Jan 9, 2018
Copy link
Contributor

@Bargs Bargs left a comment

Choose a reason for hiding this comment

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

This fix should probably go in the phrase filter constructor itself. We already have the same conversion logic there for scripted fields.

function getConvertedValueForField(field, value) {
if (typeof value !== 'boolean' && field.type === 'boolean') {
if (value !== 1 && value !== 0) {
throw new Error('Boolean scripted fields must return true or false');
}
return value === 1 ? true : false;
}
return value;
}

I'm also wondering whether this is breaking people's saved objects and we just haven't heard about it. Say someone saved one of these filters with 0/1 on a vis or dashboard in 5.x. When they try to load that object in 6.x it's going to error, right? I wonder if we should also convert those legacy filters at query time so users don't have to go through and fix everything manually. We already do this for one legacy syntax:

export function migrateFilter(filter) {

@ppisljar
Copy link
Member Author

i confirmed with @Bargs that this is now a good approach

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:Visualizations Generic visualization features (in case no more specific feature label is available) release_note:fix review v6.2.0 v7.0.0
Projects
None yet
4 participants