Skip to content

Commit

Permalink
Add IS NOT NULL and IS NULL as filter options (apache#5375)
Browse files Browse the repository at this point in the history
* wip

* disable value selector on IS NOT NULL or NOT NULL

* remove this

(cherry picked from commit e79bb92)
  • Loading branch information
hughhhh authored and mistercrunch committed Jul 31, 2018
1 parent 4cf0b11 commit 884d7cc
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 1 deletion.
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

0 comments on commit 884d7cc

Please sign in to comment.