mirror of
https://github.com/ToolJet/ToolJet
synced 2026-05-23 08:58:26 +00:00
Merge pull request #6182 from ToolJet/feat/add_is_operator
feat: Add is operator in tooljet db query manager
This commit is contained in:
commit
97b9608e28
7 changed files with 73 additions and 29 deletions
|
|
@ -4,6 +4,7 @@ import { uniqueId } from 'lodash';
|
|||
import { CodeHinter } from '@/Editor/CodeBuilder/CodeHinter';
|
||||
import Select from '@/_ui/Select';
|
||||
import { operators } from '@/TooljetDatabase/constants';
|
||||
import { isOperatorOptions } from './util';
|
||||
|
||||
export const DeleteRows = React.memo(({ currentState, darkMode }) => {
|
||||
const { columns, deleteOperationLimitOptionChanged, deleteRowsOptions, handleDeleteRowsOptionsChange } =
|
||||
|
|
@ -83,15 +84,25 @@ export const DeleteRows = React.memo(({ currentState, darkMode }) => {
|
|||
/>
|
||||
</div>
|
||||
<div className="field col-4">
|
||||
<CodeHinter
|
||||
currentState={currentState}
|
||||
initialValue={value ? (typeof value === 'string' ? value : JSON.stringify(value)) : value}
|
||||
className="codehinter-plugins"
|
||||
theme={darkMode ? 'monokai' : 'default'}
|
||||
height={'32px'}
|
||||
placeholder="key"
|
||||
onChange={(newValue) => handleValueChange(newValue)}
|
||||
/>
|
||||
{operator === 'is' ? (
|
||||
<Select
|
||||
useMenuPortal={true}
|
||||
placeholder="Select value"
|
||||
value={value}
|
||||
options={isOperatorOptions}
|
||||
onChange={handleValueChange}
|
||||
/>
|
||||
) : (
|
||||
<CodeHinter
|
||||
currentState={currentState}
|
||||
initialValue={value ? (typeof value === 'string' ? value : JSON.stringify(value)) : value}
|
||||
className="codehinter-plugins"
|
||||
theme={darkMode ? 'monokai' : 'default'}
|
||||
height={'32px'}
|
||||
placeholder="key"
|
||||
onChange={(newValue) => handleValueChange(newValue)}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
<div className="col-1 cursor-pointer m-1 mr-2">
|
||||
<svg
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import { TooljetDatabaseContext } from '@/TooljetDatabase/index';
|
|||
import { uniqueId } from 'lodash';
|
||||
import Select from '@/_ui/Select';
|
||||
import { operators } from '@/TooljetDatabase/constants';
|
||||
import { isOperatorOptions } from './util';
|
||||
|
||||
export const ListRows = React.memo(({ currentState, darkMode }) => {
|
||||
const { columns, listRowsOptions, limitOptionChanged, handleOptionsChange } = useContext(TooljetDatabaseContext);
|
||||
|
|
@ -116,15 +117,25 @@ export const ListRows = React.memo(({ currentState, darkMode }) => {
|
|||
/>
|
||||
</div>
|
||||
<div className="field col-4">
|
||||
<CodeHinter
|
||||
currentState={currentState}
|
||||
initialValue={value ? (typeof value === 'string' ? value : JSON.stringify(value)) : value}
|
||||
className="codehinter-plugins"
|
||||
theme={darkMode ? 'monokai' : 'default'}
|
||||
height={'32px'}
|
||||
placeholder="key"
|
||||
onChange={(newValue) => handleValueChange(newValue)}
|
||||
/>
|
||||
{operator === 'is' ? (
|
||||
<Select
|
||||
useMenuPortal={true}
|
||||
placeholder="Select value"
|
||||
value={value}
|
||||
options={isOperatorOptions}
|
||||
onChange={handleValueChange}
|
||||
/>
|
||||
) : (
|
||||
<CodeHinter
|
||||
currentState={currentState}
|
||||
initialValue={value ? (typeof value === 'string' ? value : JSON.stringify(value)) : value}
|
||||
className="codehinter-plugins"
|
||||
theme={darkMode ? 'monokai' : 'default'}
|
||||
height={'32px'}
|
||||
placeholder="key"
|
||||
onChange={(newValue) => handleValueChange(newValue)}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
<div className="col-1 cursor-pointer m-1 mr-2">
|
||||
<svg
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import { TooljetDatabaseContext } from '@/TooljetDatabase/index';
|
|||
import Select from '@/_ui/Select';
|
||||
import { operators } from '@/TooljetDatabase/constants';
|
||||
import { uniqueId } from 'lodash';
|
||||
import { isOperatorOptions } from './util';
|
||||
|
||||
export const UpdateRows = React.memo(({ currentState, darkMode }) => {
|
||||
const { columns, updateRowsOptions, handleUpdateRowsOptionsChange } = useContext(TooljetDatabaseContext);
|
||||
|
|
@ -109,15 +110,25 @@ export const UpdateRows = React.memo(({ currentState, darkMode }) => {
|
|||
/>
|
||||
</div>
|
||||
<div className="field col-4">
|
||||
<CodeHinter
|
||||
currentState={currentState}
|
||||
initialValue={value ? (typeof value === 'string' ? value : JSON.stringify(value)) : value}
|
||||
className="codehinter-plugins"
|
||||
theme={darkMode ? 'monokai' : 'default'}
|
||||
height={'32px'}
|
||||
placeholder="key"
|
||||
onChange={(newValue) => handleValueChange(newValue)}
|
||||
/>
|
||||
{operator === 'is' ? (
|
||||
<Select
|
||||
useMenuPortal={true}
|
||||
placeholder="Select value"
|
||||
value={value}
|
||||
options={isOperatorOptions}
|
||||
onChange={handleValueChange}
|
||||
/>
|
||||
) : (
|
||||
<CodeHinter
|
||||
currentState={currentState}
|
||||
initialValue={value ? (typeof value === 'string' ? value : JSON.stringify(value)) : value}
|
||||
className="codehinter-plugins"
|
||||
theme={darkMode ? 'monokai' : 'default'}
|
||||
height={'32px'}
|
||||
placeholder="key"
|
||||
onChange={(newValue) => handleValueChange(newValue)}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
<div className="col-1 cursor-pointer m-1 mr-2">
|
||||
<svg
|
||||
|
|
|
|||
|
|
@ -49,7 +49,6 @@ function buildPostgrestQuery(filters) {
|
|||
}
|
||||
}
|
||||
});
|
||||
|
||||
return postgrestQueryBuilder.url.toString();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import { get } from 'lodash';
|
||||
|
||||
/**
|
||||
* Checks if the queryOptions object contains a filter with an 'eq' (equal) operator and a value equal to '{{null}}'.
|
||||
*
|
||||
|
|
@ -34,3 +35,8 @@ export const hasEqualWithNull = (queryOptions, operation) => {
|
|||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
export const isOperatorOptions = [
|
||||
{ value: 'null', label: 'null' },
|
||||
{ value: 'notNull', label: 'not null' },
|
||||
];
|
||||
|
|
|
|||
|
|
@ -19,4 +19,5 @@ export const operators = [
|
|||
{ value: 'match', label: 'match' },
|
||||
{ value: 'imatch', label: 'imatch' },
|
||||
{ value: 'in', label: 'in' },
|
||||
{ value: 'is', label: 'is' },
|
||||
];
|
||||
|
|
|
|||
|
|
@ -132,9 +132,14 @@ export default class PostgrestQueryBuilder {
|
|||
* @param value The value to filter with.
|
||||
*/
|
||||
is(column, value) {
|
||||
this.url.append(`${column}`, `is.${value}`);
|
||||
if (value === 'notNull') {
|
||||
this.url.append(`${column}`, `not.is.null`);
|
||||
} else {
|
||||
this.url.append(`${column}`, `is.${value}`);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds all rows whose value on the stated `column` is found on the
|
||||
* specified `values`.
|
||||
|
|
|
|||
Loading…
Reference in a new issue