@gingkoo/pandora-metabase 1.0.158-alpha.1 → 1.0.158-alpha.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/components/dialog/expression/index.js +3 -3
- package/lib/cjs/components/dialog/formula/index.js +1 -1
- package/lib/cjs/components/dialog/formula-list/index.js +3 -3
- package/lib/cjs/components/dialog/formula-list/utils.d.ts +4 -4
- package/lib/cjs/components/dialog/formula-list/utils.js +18 -9
- package/lib/cjs/components/modules/table-data.js +2 -0
- package/lib/es/components/dialog/expression/index.js +3 -3
- package/lib/es/components/dialog/formula/index.js +1 -1
- package/lib/es/components/dialog/formula-list/index.js +3 -3
- package/lib/es/components/dialog/formula-list/utils.d.ts +4 -4
- package/lib/es/components/dialog/formula-list/utils.js +18 -9
- package/lib/es/components/modules/table-data.js +2 -0
- package/package.json +1 -1
|
@@ -76,7 +76,7 @@ var SelectFilterColumn = function SelectFilterColumn(_ref) {
|
|
|
76
76
|
_ref$filterCustomType = _ref.filterCustomType,
|
|
77
77
|
filterCustomType = _ref$filterCustomType === void 0 ? false : _ref$filterCustomType,
|
|
78
78
|
parentPopupChannel = _ref.parentPopupChannel;
|
|
79
|
-
var normalizedInitialValue = (0, _utils.normalizeExpressionAtom)(value, data);
|
|
79
|
+
var normalizedInitialValue = (0, _utils.normalizeExpressionAtom)(value, data, filterCustomType);
|
|
80
80
|
var _useState = (0, _react.useState)(normalizedInitialValue),
|
|
81
81
|
_useState2 = (0, _slicedToArray2["default"])(_useState, 2),
|
|
82
82
|
curColumn = _useState2[0],
|
|
@@ -333,7 +333,7 @@ var SelectFilterColumn = function SelectFilterColumn(_ref) {
|
|
|
333
333
|
rhs: rhsVal,
|
|
334
334
|
condition: condition,
|
|
335
335
|
database_type: databaseType
|
|
336
|
-
}), filterCustomType
|
|
336
|
+
}), data, filterCustomType);
|
|
337
337
|
var quotes = generateQuotes(nextExpression.rhs, nextExpression);
|
|
338
338
|
typeof onChange === 'function' && onChange((0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, nextExpression), {}, {
|
|
339
339
|
quotes: quotes
|
|
@@ -1020,7 +1020,7 @@ var SelectFilterColumn = function SelectFilterColumn(_ref) {
|
|
|
1020
1020
|
onSelect: function onSelect(fields, quotes) {
|
|
1021
1021
|
setCurColumn((0, _utils.normalizeExpressionAtom)((0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, curColumn), {}, {
|
|
1022
1022
|
lhs: fields
|
|
1023
|
-
}), data));
|
|
1023
|
+
}), data, filterCustomType));
|
|
1024
1024
|
setIsNext(true);
|
|
1025
1025
|
}
|
|
1026
1026
|
})
|
|
@@ -91,7 +91,7 @@ var CaseEditor = _react["default"].forwardRef(function (props, ref) {
|
|
|
91
91
|
rightClickMenuState = _useState6[0],
|
|
92
92
|
setRightClickMenuState = _useState6[1];
|
|
93
93
|
var usable = (0, _react.useMemo)(function () {
|
|
94
|
-
return fun.name && (0, _utils.isOk)(fun.args);
|
|
94
|
+
return fun.name && (0, _utils.isOk)(fun.args, true);
|
|
95
95
|
}, [fun]);
|
|
96
96
|
var _onClose = function _onClose() {
|
|
97
97
|
onCancel === null || onCancel === void 0 || onCancel();
|
|
@@ -1056,8 +1056,8 @@ var FormulaList = (0, _react.forwardRef)(function (props, ref) {
|
|
|
1056
1056
|
return (0, _utils2.normalizeAndOrStructure)(value || []);
|
|
1057
1057
|
}, [value]);
|
|
1058
1058
|
var normalizedExpressionValue = (0, _react.useMemo)(function () {
|
|
1059
|
-
return (0, _utils3.normalizeExpressionAtoms)(normalizedStructureValue, data);
|
|
1060
|
-
}, [normalizedStructureValue, data]);
|
|
1059
|
+
return (0, _utils3.normalizeExpressionAtoms)(normalizedStructureValue, data, store.filterCustomType);
|
|
1060
|
+
}, [normalizedStructureValue, data, store.filterCustomType]);
|
|
1061
1061
|
var normalizedValue = (0, _react.useMemo)(function () {
|
|
1062
1062
|
return normalizedExpressionValue.map(_utils2.syncAtomQuotes);
|
|
1063
1063
|
}, [normalizedExpressionValue]);
|
|
@@ -1281,7 +1281,7 @@ var FormulaList = (0, _react.forwardRef)(function (props, ref) {
|
|
|
1281
1281
|
return _withSyncedQuotesInner(item, new WeakMap());
|
|
1282
1282
|
};
|
|
1283
1283
|
var setCaseList = function setCaseList(atoms) {
|
|
1284
|
-
var nextData = (0, _utils3.normalizeExpressionAtoms)(atoms, data).map(function (item) {
|
|
1284
|
+
var nextData = (0, _utils3.normalizeExpressionAtoms)(atoms, data, store.filterCustomType).map(function (item) {
|
|
1285
1285
|
return withSyncedQuotes(item);
|
|
1286
1286
|
});
|
|
1287
1287
|
var quotes = nextData.map(function (item) {
|
|
@@ -7,9 +7,9 @@ type ExpressionTable = {
|
|
|
7
7
|
columns?: any[];
|
|
8
8
|
};
|
|
9
9
|
export declare const EMPTY_RHS_CONDITIONS: Set<string>;
|
|
10
|
-
export declare const getExpressionDatabaseType: (expression: AtomsExpression, tables?: ExpressionTable[]) => string;
|
|
11
|
-
export declare const normalizeExpressionAtom: (expression: AtomsExpression, tables?: ExpressionTable[]) => AtomsExpression;
|
|
12
|
-
export declare const normalizeExpressionAtoms: (atoms?: AtomsItem[], tables?: ExpressionTable[]) => AtomsItem[];
|
|
10
|
+
export declare const getExpressionDatabaseType: (expression: AtomsExpression, tables?: ExpressionTable[], filterCustomType?: boolean) => string;
|
|
11
|
+
export declare const normalizeExpressionAtom: (expression: AtomsExpression, tables?: ExpressionTable[], filterCustomType?: boolean) => AtomsExpression;
|
|
12
|
+
export declare const normalizeExpressionAtoms: (atoms?: AtomsItem[], tables?: ExpressionTable[], filterCustomType?: boolean) => AtomsItem[];
|
|
13
13
|
export declare const insertTemplateAt: (oldType: string, type: string, list: any[], index: number) => any[];
|
|
14
14
|
export declare const operatorList: string[];
|
|
15
15
|
export declare const customTypes: ({
|
|
@@ -22,7 +22,7 @@ export declare const customTypes: ({
|
|
|
22
22
|
children: string[];
|
|
23
23
|
})[];
|
|
24
24
|
export declare const getTemplateItem: (type: AtomsTypeEnum, item?: any) => AtomsItem;
|
|
25
|
-
export declare const isOk: (rhsVal: AtomsItem[]) => boolean;
|
|
25
|
+
export declare const isOk: (rhsVal: AtomsItem[], allowEmptyInputString?: boolean) => boolean;
|
|
26
26
|
export declare function validateExpressionIntegrity(list: AtomsItem[]): {
|
|
27
27
|
isError: boolean;
|
|
28
28
|
error?: string;
|
|
@@ -36,6 +36,10 @@ var findExpressionColumn = function findExpressionColumn(expression) {
|
|
|
36
36
|
};
|
|
37
37
|
var getExpressionDatabaseType = exports.getExpressionDatabaseType = function getExpressionDatabaseType(expression) {
|
|
38
38
|
var tables = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
39
|
+
var filterCustomType = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
40
|
+
if (filterCustomType) {
|
|
41
|
+
return String(expression.database_type || '').toUpperCase();
|
|
42
|
+
}
|
|
39
43
|
var column = findExpressionColumn(expression, tables);
|
|
40
44
|
return String((column === null || column === void 0 ? void 0 : column.database_type) || expression.database_type || '').toUpperCase();
|
|
41
45
|
};
|
|
@@ -45,7 +49,8 @@ var normalizeExpressionRhs = function normalizeExpressionRhs(expression) {
|
|
|
45
49
|
};
|
|
46
50
|
var normalizeExpressionAtom = exports.normalizeExpressionAtom = function normalizeExpressionAtom(expression) {
|
|
47
51
|
var tables = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
48
|
-
var
|
|
52
|
+
var filterCustomType = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
53
|
+
var databaseType = getExpressionDatabaseType(expression, tables, filterCustomType);
|
|
49
54
|
return (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, expression), {}, {
|
|
50
55
|
lhs: expression.lhs || [],
|
|
51
56
|
rhs: normalizeExpressionRhs(expression),
|
|
@@ -55,6 +60,7 @@ var normalizeExpressionAtom = exports.normalizeExpressionAtom = function normali
|
|
|
55
60
|
var normalizeExpressionAtoms = exports.normalizeExpressionAtoms = function normalizeExpressionAtoms() {
|
|
56
61
|
var atoms = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
57
62
|
var tables = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
63
|
+
var filterCustomType = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
58
64
|
var normalizeList = function normalizeList() {
|
|
59
65
|
var items = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
60
66
|
return items.map(normalizeItem);
|
|
@@ -62,7 +68,7 @@ var normalizeExpressionAtoms = exports.normalizeExpressionAtoms = function norma
|
|
|
62
68
|
var normalizeItem = function normalizeItem(item) {
|
|
63
69
|
if (!item || (0, _typeof2["default"])(item) !== 'object') return item;
|
|
64
70
|
if (item.type === _types.AtomsTypeEnum.EXPRESSION) {
|
|
65
|
-
var nextExpression = normalizeExpressionAtom(item, tables);
|
|
71
|
+
var nextExpression = normalizeExpressionAtom(item, tables, filterCustomType);
|
|
66
72
|
return (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, nextExpression), {}, {
|
|
67
73
|
lhs: normalizeList(nextExpression.lhs),
|
|
68
74
|
rhs: normalizeList(nextExpression.rhs)
|
|
@@ -360,6 +366,7 @@ var getTemplateItem = exports.getTemplateItem = function getTemplateItem(type, i
|
|
|
360
366
|
return temItem;
|
|
361
367
|
};
|
|
362
368
|
var _isOk = exports.isOk = function isOk(rhsVal) {
|
|
369
|
+
var allowEmptyInputString = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
363
370
|
return rhsVal.every(function (v) {
|
|
364
371
|
if (v.type === _types.AtomsTypeEnum.UNKNOWN) {
|
|
365
372
|
return false;
|
|
@@ -369,36 +376,38 @@ var _isOk = exports.isOk = function isOk(rhsVal) {
|
|
|
369
376
|
return Boolean(v.fieldName);
|
|
370
377
|
} else if (v.type === _types.AtomsTypeEnum.EXPRESSION || v.type === _types.AtomsTypeEnum.EXISTS || v.type === _types.AtomsTypeEnum.NOT_EXISTS || v.type === _types.AtomsTypeEnum.SUB_QUERY) {
|
|
371
378
|
return Boolean(v.quotes);
|
|
379
|
+
} else if (v.type === _types.AtomsTypeEnum.INPUT_STRING) {
|
|
380
|
+
return allowEmptyInputString ? typeof v.val === 'string' : Boolean(v.val);
|
|
372
381
|
} else if (v.type === _types.AtomsTypeEnum.INPUT_STRING_LIST) {
|
|
373
382
|
return Array.isArray(v.val) && v.val.every(function (vv) {
|
|
374
383
|
return Boolean(vv);
|
|
375
384
|
});
|
|
376
385
|
} else if (v.type === _types.AtomsTypeEnum.COLLECTION) {
|
|
377
|
-
return _isOk(v.list || []);
|
|
386
|
+
return _isOk(v.list || [], allowEmptyInputString);
|
|
378
387
|
} else if (v.type === _types.AtomsTypeEnum.CASE_WHEN) {
|
|
379
388
|
return (v.whenClauses || []).length > 0 && (v.whenClauses || []).every(function (clause) {
|
|
380
|
-
return _isOk(clause.whenAtoms || []) && _isOk(clause.thenAtoms || []);
|
|
381
|
-
}) && _isOk(v.caseAtoms || []) && _isOk(v.elseAtoms || []);
|
|
389
|
+
return _isOk(clause.whenAtoms || [], allowEmptyInputString) && _isOk(clause.thenAtoms || [], allowEmptyInputString);
|
|
390
|
+
}) && _isOk(v.caseAtoms || [], allowEmptyInputString) && _isOk(v.elseAtoms || [], allowEmptyInputString);
|
|
382
391
|
} else if (v.type === _types.AtomsTypeEnum.AND_OR) {
|
|
383
392
|
if (Array.isArray(v.items) && v.items.length > 0) {
|
|
384
393
|
return v.items.every(function (item, index) {
|
|
385
394
|
var _item$atoms;
|
|
386
395
|
if (index > 0 && !item.operator) return false;
|
|
387
|
-
return Boolean((_item$atoms = item.atoms) === null || _item$atoms === void 0 ? void 0 : _item$atoms.length) && _isOk(item.atoms || []);
|
|
396
|
+
return Boolean((_item$atoms = item.atoms) === null || _item$atoms === void 0 ? void 0 : _item$atoms.length) && _isOk(item.atoms || [], allowEmptyInputString);
|
|
388
397
|
});
|
|
389
398
|
}
|
|
390
399
|
var legacyItem = v;
|
|
391
400
|
var hasBinarySides = Array.isArray(legacyItem.leftAtoms) || Array.isArray(legacyItem.rightAtoms);
|
|
392
401
|
if (hasBinarySides) {
|
|
393
402
|
var _legacyItem$leftAtoms, _legacyItem$rightAtom;
|
|
394
|
-
return Boolean(legacyItem.operator) && Boolean((_legacyItem$leftAtoms = legacyItem.leftAtoms) === null || _legacyItem$leftAtoms === void 0 ? void 0 : _legacyItem$leftAtoms.length) && Boolean((_legacyItem$rightAtom = legacyItem.rightAtoms) === null || _legacyItem$rightAtom === void 0 ? void 0 : _legacyItem$rightAtom.length) && _isOk(legacyItem.leftAtoms || []) && _isOk(legacyItem.rightAtoms || []);
|
|
403
|
+
return Boolean(legacyItem.operator) && Boolean((_legacyItem$leftAtoms = legacyItem.leftAtoms) === null || _legacyItem$leftAtoms === void 0 ? void 0 : _legacyItem$leftAtoms.length) && Boolean((_legacyItem$rightAtom = legacyItem.rightAtoms) === null || _legacyItem$rightAtom === void 0 ? void 0 : _legacyItem$rightAtom.length) && _isOk(legacyItem.leftAtoms || [], allowEmptyInputString) && _isOk(legacyItem.rightAtoms || [], allowEmptyInputString);
|
|
395
404
|
}
|
|
396
|
-
return Boolean(legacyItem.operator) && _isOk(legacyItem.atoms || []);
|
|
405
|
+
return Boolean(legacyItem.operator) && _isOk(legacyItem.atoms || [], allowEmptyInputString);
|
|
397
406
|
} else if (v.type === _types.AtomsTypeEnum.FORMULA) {
|
|
398
407
|
if (!v.quotes) {
|
|
399
408
|
return false;
|
|
400
409
|
}
|
|
401
|
-
return _isOk(v.args || []);
|
|
410
|
+
return _isOk(v.args || [], allowEmptyInputString);
|
|
402
411
|
} else if (v.type === _types.AtomsTypeEnum.SELECT) {
|
|
403
412
|
return Array.isArray(v.val) ? v.val.length > 0 : Boolean(v.val);
|
|
404
413
|
} else {
|
|
@@ -207,6 +207,8 @@ var TableData = function TableData(props) {
|
|
|
207
207
|
children: (0, _jsxRuntime.jsx)(_index["default"], (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, other), {}, {
|
|
208
208
|
popupZIndex: childModalZIndex + 1,
|
|
209
209
|
showSubquery: store._showSubquery,
|
|
210
|
+
isExit: isExit,
|
|
211
|
+
isSubquery: true,
|
|
210
212
|
toolbar: _toolbar,
|
|
211
213
|
btnText: (0, _locale.__)('SqlQueryBuilder.confirm'),
|
|
212
214
|
value: (0, _cloneDeep["default"])(val),
|
|
@@ -68,7 +68,7 @@ var SelectFilterColumn = function SelectFilterColumn(_ref) {
|
|
|
68
68
|
_ref$filterCustomType = _ref.filterCustomType,
|
|
69
69
|
filterCustomType = _ref$filterCustomType === void 0 ? false : _ref$filterCustomType,
|
|
70
70
|
parentPopupChannel = _ref.parentPopupChannel;
|
|
71
|
-
var normalizedInitialValue = normalizeExpressionAtom(value, data);
|
|
71
|
+
var normalizedInitialValue = normalizeExpressionAtom(value, data, filterCustomType);
|
|
72
72
|
var _useState = useState(normalizedInitialValue),
|
|
73
73
|
_useState2 = _slicedToArray(_useState, 2),
|
|
74
74
|
curColumn = _useState2[0],
|
|
@@ -325,7 +325,7 @@ var SelectFilterColumn = function SelectFilterColumn(_ref) {
|
|
|
325
325
|
rhs: rhsVal,
|
|
326
326
|
condition: condition,
|
|
327
327
|
database_type: databaseType
|
|
328
|
-
}), filterCustomType
|
|
328
|
+
}), data, filterCustomType);
|
|
329
329
|
var quotes = generateQuotes(nextExpression.rhs, nextExpression);
|
|
330
330
|
typeof onChange === 'function' && onChange(_objectSpread(_objectSpread({}, nextExpression), {}, {
|
|
331
331
|
quotes: quotes
|
|
@@ -1012,7 +1012,7 @@ var SelectFilterColumn = function SelectFilterColumn(_ref) {
|
|
|
1012
1012
|
onSelect: function onSelect(fields, quotes) {
|
|
1013
1013
|
setCurColumn(normalizeExpressionAtom(_objectSpread(_objectSpread({}, curColumn), {}, {
|
|
1014
1014
|
lhs: fields
|
|
1015
|
-
}), data));
|
|
1015
|
+
}), data, filterCustomType));
|
|
1016
1016
|
setIsNext(true);
|
|
1017
1017
|
}
|
|
1018
1018
|
})
|
|
@@ -82,7 +82,7 @@ var CaseEditor = React.forwardRef(function (props, ref) {
|
|
|
82
82
|
rightClickMenuState = _useState6[0],
|
|
83
83
|
setRightClickMenuState = _useState6[1];
|
|
84
84
|
var usable = useMemo(function () {
|
|
85
|
-
return fun.name && isOk(fun.args);
|
|
85
|
+
return fun.name && isOk(fun.args, true);
|
|
86
86
|
}, [fun]);
|
|
87
87
|
var _onClose = function _onClose() {
|
|
88
88
|
onCancel === null || onCancel === void 0 || onCancel();
|
|
@@ -1047,8 +1047,8 @@ var FormulaList = forwardRef(function (props, ref) {
|
|
|
1047
1047
|
return normalizeAndOrStructure(value || []);
|
|
1048
1048
|
}, [value]);
|
|
1049
1049
|
var normalizedExpressionValue = useMemo(function () {
|
|
1050
|
-
return normalizeExpressionAtoms(normalizedStructureValue, data);
|
|
1051
|
-
}, [normalizedStructureValue, data]);
|
|
1050
|
+
return normalizeExpressionAtoms(normalizedStructureValue, data, store.filterCustomType);
|
|
1051
|
+
}, [normalizedStructureValue, data, store.filterCustomType]);
|
|
1052
1052
|
var normalizedValue = useMemo(function () {
|
|
1053
1053
|
return normalizedExpressionValue.map(syncAtomQuotes);
|
|
1054
1054
|
}, [normalizedExpressionValue]);
|
|
@@ -1272,7 +1272,7 @@ var FormulaList = forwardRef(function (props, ref) {
|
|
|
1272
1272
|
return _withSyncedQuotesInner(item, new WeakMap());
|
|
1273
1273
|
};
|
|
1274
1274
|
var setCaseList = function setCaseList(atoms) {
|
|
1275
|
-
var nextData = normalizeExpressionAtoms(atoms, data).map(function (item) {
|
|
1275
|
+
var nextData = normalizeExpressionAtoms(atoms, data, store.filterCustomType).map(function (item) {
|
|
1276
1276
|
return withSyncedQuotes(item);
|
|
1277
1277
|
});
|
|
1278
1278
|
var quotes = nextData.map(function (item) {
|
|
@@ -7,9 +7,9 @@ type ExpressionTable = {
|
|
|
7
7
|
columns?: any[];
|
|
8
8
|
};
|
|
9
9
|
export declare const EMPTY_RHS_CONDITIONS: Set<string>;
|
|
10
|
-
export declare const getExpressionDatabaseType: (expression: AtomsExpression, tables?: ExpressionTable[]) => string;
|
|
11
|
-
export declare const normalizeExpressionAtom: (expression: AtomsExpression, tables?: ExpressionTable[]) => AtomsExpression;
|
|
12
|
-
export declare const normalizeExpressionAtoms: (atoms?: AtomsItem[], tables?: ExpressionTable[]) => AtomsItem[];
|
|
10
|
+
export declare const getExpressionDatabaseType: (expression: AtomsExpression, tables?: ExpressionTable[], filterCustomType?: boolean) => string;
|
|
11
|
+
export declare const normalizeExpressionAtom: (expression: AtomsExpression, tables?: ExpressionTable[], filterCustomType?: boolean) => AtomsExpression;
|
|
12
|
+
export declare const normalizeExpressionAtoms: (atoms?: AtomsItem[], tables?: ExpressionTable[], filterCustomType?: boolean) => AtomsItem[];
|
|
13
13
|
export declare const insertTemplateAt: (oldType: string, type: string, list: any[], index: number) => any[];
|
|
14
14
|
export declare const operatorList: string[];
|
|
15
15
|
export declare const customTypes: ({
|
|
@@ -22,7 +22,7 @@ export declare const customTypes: ({
|
|
|
22
22
|
children: string[];
|
|
23
23
|
})[];
|
|
24
24
|
export declare const getTemplateItem: (type: AtomsTypeEnum, item?: any) => AtomsItem;
|
|
25
|
-
export declare const isOk: (rhsVal: AtomsItem[]) => boolean;
|
|
25
|
+
export declare const isOk: (rhsVal: AtomsItem[], allowEmptyInputString?: boolean) => boolean;
|
|
26
26
|
export declare function validateExpressionIntegrity(list: AtomsItem[]): {
|
|
27
27
|
isError: boolean;
|
|
28
28
|
error?: string;
|
|
@@ -28,6 +28,10 @@ var findExpressionColumn = function findExpressionColumn(expression) {
|
|
|
28
28
|
};
|
|
29
29
|
export var getExpressionDatabaseType = function getExpressionDatabaseType(expression) {
|
|
30
30
|
var tables = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
31
|
+
var filterCustomType = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
32
|
+
if (filterCustomType) {
|
|
33
|
+
return String(expression.database_type || '').toUpperCase();
|
|
34
|
+
}
|
|
31
35
|
var column = findExpressionColumn(expression, tables);
|
|
32
36
|
return String((column === null || column === void 0 ? void 0 : column.database_type) || expression.database_type || '').toUpperCase();
|
|
33
37
|
};
|
|
@@ -37,7 +41,8 @@ var normalizeExpressionRhs = function normalizeExpressionRhs(expression) {
|
|
|
37
41
|
};
|
|
38
42
|
export var normalizeExpressionAtom = function normalizeExpressionAtom(expression) {
|
|
39
43
|
var tables = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
40
|
-
var
|
|
44
|
+
var filterCustomType = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
45
|
+
var databaseType = getExpressionDatabaseType(expression, tables, filterCustomType);
|
|
41
46
|
return _objectSpread(_objectSpread({}, expression), {}, {
|
|
42
47
|
lhs: expression.lhs || [],
|
|
43
48
|
rhs: normalizeExpressionRhs(expression),
|
|
@@ -47,6 +52,7 @@ export var normalizeExpressionAtom = function normalizeExpressionAtom(expression
|
|
|
47
52
|
export var normalizeExpressionAtoms = function normalizeExpressionAtoms() {
|
|
48
53
|
var atoms = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
49
54
|
var tables = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
55
|
+
var filterCustomType = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
50
56
|
var normalizeList = function normalizeList() {
|
|
51
57
|
var items = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
52
58
|
return items.map(normalizeItem);
|
|
@@ -54,7 +60,7 @@ export var normalizeExpressionAtoms = function normalizeExpressionAtoms() {
|
|
|
54
60
|
var normalizeItem = function normalizeItem(item) {
|
|
55
61
|
if (!item || _typeof(item) !== 'object') return item;
|
|
56
62
|
if (item.type === AtomsTypeEnum.EXPRESSION) {
|
|
57
|
-
var nextExpression = normalizeExpressionAtom(item, tables);
|
|
63
|
+
var nextExpression = normalizeExpressionAtom(item, tables, filterCustomType);
|
|
58
64
|
return _objectSpread(_objectSpread({}, nextExpression), {}, {
|
|
59
65
|
lhs: normalizeList(nextExpression.lhs),
|
|
60
66
|
rhs: normalizeList(nextExpression.rhs)
|
|
@@ -352,6 +358,7 @@ export var getTemplateItem = function getTemplateItem(type, item) {
|
|
|
352
358
|
return temItem;
|
|
353
359
|
};
|
|
354
360
|
var _isOk = function isOk(rhsVal) {
|
|
361
|
+
var allowEmptyInputString = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
355
362
|
return rhsVal.every(function (v) {
|
|
356
363
|
if (v.type === AtomsTypeEnum.UNKNOWN) {
|
|
357
364
|
return false;
|
|
@@ -361,36 +368,38 @@ var _isOk = function isOk(rhsVal) {
|
|
|
361
368
|
return Boolean(v.fieldName);
|
|
362
369
|
} else if (v.type === AtomsTypeEnum.EXPRESSION || v.type === AtomsTypeEnum.EXISTS || v.type === AtomsTypeEnum.NOT_EXISTS || v.type === AtomsTypeEnum.SUB_QUERY) {
|
|
363
370
|
return Boolean(v.quotes);
|
|
371
|
+
} else if (v.type === AtomsTypeEnum.INPUT_STRING) {
|
|
372
|
+
return allowEmptyInputString ? typeof v.val === 'string' : Boolean(v.val);
|
|
364
373
|
} else if (v.type === AtomsTypeEnum.INPUT_STRING_LIST) {
|
|
365
374
|
return Array.isArray(v.val) && v.val.every(function (vv) {
|
|
366
375
|
return Boolean(vv);
|
|
367
376
|
});
|
|
368
377
|
} else if (v.type === AtomsTypeEnum.COLLECTION) {
|
|
369
|
-
return _isOk(v.list || []);
|
|
378
|
+
return _isOk(v.list || [], allowEmptyInputString);
|
|
370
379
|
} else if (v.type === AtomsTypeEnum.CASE_WHEN) {
|
|
371
380
|
return (v.whenClauses || []).length > 0 && (v.whenClauses || []).every(function (clause) {
|
|
372
|
-
return _isOk(clause.whenAtoms || []) && _isOk(clause.thenAtoms || []);
|
|
373
|
-
}) && _isOk(v.caseAtoms || []) && _isOk(v.elseAtoms || []);
|
|
381
|
+
return _isOk(clause.whenAtoms || [], allowEmptyInputString) && _isOk(clause.thenAtoms || [], allowEmptyInputString);
|
|
382
|
+
}) && _isOk(v.caseAtoms || [], allowEmptyInputString) && _isOk(v.elseAtoms || [], allowEmptyInputString);
|
|
374
383
|
} else if (v.type === AtomsTypeEnum.AND_OR) {
|
|
375
384
|
if (Array.isArray(v.items) && v.items.length > 0) {
|
|
376
385
|
return v.items.every(function (item, index) {
|
|
377
386
|
var _item$atoms;
|
|
378
387
|
if (index > 0 && !item.operator) return false;
|
|
379
|
-
return Boolean((_item$atoms = item.atoms) === null || _item$atoms === void 0 ? void 0 : _item$atoms.length) && _isOk(item.atoms || []);
|
|
388
|
+
return Boolean((_item$atoms = item.atoms) === null || _item$atoms === void 0 ? void 0 : _item$atoms.length) && _isOk(item.atoms || [], allowEmptyInputString);
|
|
380
389
|
});
|
|
381
390
|
}
|
|
382
391
|
var legacyItem = v;
|
|
383
392
|
var hasBinarySides = Array.isArray(legacyItem.leftAtoms) || Array.isArray(legacyItem.rightAtoms);
|
|
384
393
|
if (hasBinarySides) {
|
|
385
394
|
var _legacyItem$leftAtoms, _legacyItem$rightAtom;
|
|
386
|
-
return Boolean(legacyItem.operator) && Boolean((_legacyItem$leftAtoms = legacyItem.leftAtoms) === null || _legacyItem$leftAtoms === void 0 ? void 0 : _legacyItem$leftAtoms.length) && Boolean((_legacyItem$rightAtom = legacyItem.rightAtoms) === null || _legacyItem$rightAtom === void 0 ? void 0 : _legacyItem$rightAtom.length) && _isOk(legacyItem.leftAtoms || []) && _isOk(legacyItem.rightAtoms || []);
|
|
395
|
+
return Boolean(legacyItem.operator) && Boolean((_legacyItem$leftAtoms = legacyItem.leftAtoms) === null || _legacyItem$leftAtoms === void 0 ? void 0 : _legacyItem$leftAtoms.length) && Boolean((_legacyItem$rightAtom = legacyItem.rightAtoms) === null || _legacyItem$rightAtom === void 0 ? void 0 : _legacyItem$rightAtom.length) && _isOk(legacyItem.leftAtoms || [], allowEmptyInputString) && _isOk(legacyItem.rightAtoms || [], allowEmptyInputString);
|
|
387
396
|
}
|
|
388
|
-
return Boolean(legacyItem.operator) && _isOk(legacyItem.atoms || []);
|
|
397
|
+
return Boolean(legacyItem.operator) && _isOk(legacyItem.atoms || [], allowEmptyInputString);
|
|
389
398
|
} else if (v.type === AtomsTypeEnum.FORMULA) {
|
|
390
399
|
if (!v.quotes) {
|
|
391
400
|
return false;
|
|
392
401
|
}
|
|
393
|
-
return _isOk(v.args || []);
|
|
402
|
+
return _isOk(v.args || [], allowEmptyInputString);
|
|
394
403
|
} else if (v.type === AtomsTypeEnum.SELECT) {
|
|
395
404
|
return Array.isArray(v.val) ? v.val.length > 0 : Boolean(v.val);
|
|
396
405
|
} else {
|
|
@@ -200,6 +200,8 @@ var TableData = function TableData(props) {
|
|
|
200
200
|
children: _jsx(Metabase, _objectSpread(_objectSpread({}, other), {}, {
|
|
201
201
|
popupZIndex: childModalZIndex + 1,
|
|
202
202
|
showSubquery: store._showSubquery,
|
|
203
|
+
isExit: isExit,
|
|
204
|
+
isSubquery: true,
|
|
203
205
|
toolbar: _toolbar,
|
|
204
206
|
btnText: __('SqlQueryBuilder.confirm'),
|
|
205
207
|
value: cloneDeep(val),
|