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

Add IS NOT NULL and IS NULL as filter options #5375

Merged
merged 3 commits into from
Jul 16, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions superset/assets/src/explore/AdhocFilter.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ const OPERATORS_TO_SQL = {
'not in': 'not in',
LIKE: 'like',
regex: 'regex',
'IS NOT NULL': 'IS NOT NULL',
'IS NULL': 'IS NULL',
};

function translateToSql(adhocMetric, { useSimple } = {}) {
Expand Down Expand Up @@ -84,6 +86,13 @@ export default class AdhocFilter {

isValid() {
if (this.expressionType === EXPRESSION_TYPES.SIMPLE) {
if (this.operator === 'IS NOT NULL' || this.operator === 'IS NULL') {
return !!(
this.operator &&
this.subject
);
}

return !!(
this.operator &&
this.subject &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ export default class AdhocFilterEditPopoverSimpleTabContent extends React.Compon
showHeader={false}
noResultsText={t('type a value here')}
refFunc={this.multiComparatorRef}
disabled={adhocFilter.operator === 'IS NOT NULL' || adhocFilter.operator === 'IS NULL'}
/> :
<input
ref={this.focusComparator}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,6 @@ export default class AdhocMetricEditPopover extends React.Component {

const stateIsValid = adhocMetric.isValid();
const hasUnsavedChanges = !adhocMetric.equals(propsAdhocMetric);

return (
<Popover
id="metrics-edit-popover"
Expand Down
2 changes: 2 additions & 0 deletions superset/assets/src/explore/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ export const OPERATORS = {
'not in': 'not in',
LIKE: 'LIKE',
regex: 'regex',
'IS NOT NULL': 'IS NOT NULL',
'IS NULL': 'IS NULL',
};

export const TABLE_ONLY_OPERATORS = [OPERATORS.LIKE];
Expand Down