diff --git a/console/src/components/Services/Data/TableBrowseRows/FilterActions.js b/console/src/components/Services/Data/TableBrowseRows/FilterActions.js index cb59fd905e255..ad0e4bcec772d 100644 --- a/console/src/components/Services/Data/TableBrowseRows/FilterActions.js +++ b/console/src/components/Services/Data/TableBrowseRows/FilterActions.js @@ -43,6 +43,15 @@ const setOffset = offset => ({ type: SET_OFFSET, offset }); const setNextPage = () => ({ type: SET_NEXTPAGE }); const setPrevPage = () => ({ type: SET_PREVPAGE }); +const parseArray = val => { + if (Array.isArray(val)) return val; + try { + return JSON.parse(val); + } catch (err) { + return ''; + } +}; + const runQuery = tableSchema => { return (dispatch, getState) => { const state = getState().tables.view.curFilter; @@ -61,6 +70,12 @@ const runQuery = tableSchema => { const colName = Object.keys(w)[0]; const opName = Object.keys(w[colName])[0]; const val = w[colName][opName]; + + if (['$in', '$nin'].includes(opName)) { + w[colName][opName] = parseArray(val); + return w; + } + const colType = tableSchema.columns.find(c => c.column_name === colName) .data_type; if (Integers.indexOf(colType) > 0) { diff --git a/console/src/components/Services/Data/TableBrowseRows/FilterQuery.js b/console/src/components/Services/Data/TableBrowseRows/FilterQuery.js index 7973982ad5b29..b9a0d36c04042 100644 --- a/console/src/components/Services/Data/TableBrowseRows/FilterQuery.js +++ b/console/src/components/Services/Data/TableBrowseRows/FilterQuery.js @@ -64,12 +64,22 @@ const renderOps = (opName, onChange, key) => ( ) : null} {Operators.map((o, i) => ( ))} ); +const getDefaultValue = (possibleValue, opName) => { + if (possibleValue) { + if (Array.isArray(possibleValue)) return JSON.stringify(possibleValue); + return possibleValue; + } + + const operator = Operators.find(op => op.value === opName); + return operator && operator.defaultValue ? operator.defaultValue : ''; +}; + const renderWheres = (whereAnd, tableSchema, dispatch) => { const styles = require('../../../Common/FilterQuery/FilterQuery.scss'); return whereAnd.map((clause, i) => { @@ -93,6 +103,7 @@ const renderWheres = (whereAnd, tableSchema, dispatch) => { /> ); } + return (