Bug #4091
closedOption "<< no preference >>" for multichoice selectors in Event search translates to probably unintended query
100%
Description
When selecting option "<< no preference >>" in multichoice dropdowns, probably incorect filtering condition is created
How to reproduce:- Set up query with Severities set to '<< no preference >>'.
- This translates to query: SELECT * FROM events WHERE "cesnet_eventseverity" = ANY ORDER BY "detecttime" DESC LIMIT 100
- This matches no data as empty string is not a variant present in data.
- Behavior confirmed for other multichoices offering "<< no preference >>" option (Source types, Categories, Classes, ...)
No preference probably means any value, then the correct approach should be to omit the filter in WHERE. This is identical to selecting no options in corresponding multichoice so '<< no preference >>' is probably redundant. Selecting other options in combination with '<< no preference >>' is meaningless so '<< no preference >>' is counterintuitive.
Option '<< no preference >>' only exists for columns containing NULL values as it is the default for get() in source:lib/hawat/blueprints/events/forms.py@devel#L131.
Related issues
Updated by Radko Krkoš over 6 years ago
- Subject changed from Option "<< no preference >>" for multichoice selectors translates to probably unintended query to Option "<< no preference >>" for multichoice selectors in Event search translates to probably unintended query
Updated by Jan Mach over 6 years ago
- Status changed from New to Feedback
- Assignee changed from Jan Mach to Radko Krkoš
- Target version set to 2.0
- % Done changed from 0 to 100
I think associated commits should resolve this issue. Details are in attached commit messages. There is still room for small improvement, the any option should be able to toggle/disable the empty option. However any and empty queries should now make sense.
Example of any query:Gimme all events with any CESNET classification (all events, that have been correctly recognized and classified by our inspection module).
Example of empty query:Gimme all events without CESNET classification (all events, that have NOT been correctly recognized and classified by our inspection module).
Updated by Radko Krkoš over 6 years ago
- Assignee changed from Radko Krkoš to Jan Mach
There is still room for small improvement, the any option should be able to toggle/disable the empty option.¶
I think exchanging the condition order (giving priority to "__ANY__") would fix this issue.
Example (hawat-common.js):
if (selected.indexOf('__ANY__') != -1) { $(e.currentTarget).selectpicker('val', ['__ANY__']); } else if (selected.indexOf('__EMPTY__') != -1) { $(e.currentTarget).selectpicker('val', ['__EMPTY__']); }
and similar reordering changes in Python code.
"__EMPTY__" mutually exclusive with other options.¶
First thought was that this should not be the case to make the querying capability fully functional, i.e. "Gimme all events classified as low OR without classification", but I came to see there is probably no use case for this.
Updated by Radko Krkoš over 6 years ago
The proposed fix for any disabling the empty option will not work as "__ANY__" really means ANY NON-NULL. Therefore "__ANY__" and "__EMPTY__" are complementary.
Updated by Jan Mach over 6 years ago
- Related to Bug #4092: Invalid option 'None' in multichoice dropdowns in Event search added
Updated by Radko Krkoš over 6 years ago
- Status changed from Feedback to Resolved
The aggregation options were replaced with:
<< without value >>
- which means events with no assigned value,
<< any value >>
- which means events with any assigned value (non-empty).
<< without value >> AND << any value >>
is logically equivalent to empty filter (no SQL condition) but results inCOALESCE(column, '') = ''
,<< any value >> AND some_enumerated_value
is logically equivalent to<< any value >>
only.
These are different issues and the original bug can be closed now.
Updated by Pavel Kácha about 6 years ago
- Assignee changed from Jan Mach to Radko Krkoš
Updated by Pavel Kácha about 6 years ago
- Status changed from Resolved to Closed
Updated by Jan Mach about 6 years ago
- Target version changed from Backlog to 2.1