@gingkoo/pandora-metabase 1.0.140 → 1.0.141-alpha.4
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/README.md +2 -3
- package/lib/cjs/components/dialog/formula-list/LogicGroup.d.ts +8 -5
- package/lib/cjs/components/dialog/formula-list/LogicGroup.js +64 -18
- package/lib/cjs/components/dialog/formula-list/index.js +374 -153
- package/lib/cjs/components/dialog/formula-list/index.less +18 -5
- package/lib/cjs/components/dialog/formula-list/utils.js +45 -17
- package/lib/cjs/components/dialog/select-summarize/index.js +7 -0
- package/lib/cjs/components/modules/summarize/group-by.js +10 -1
- package/lib/cjs/components/modules/summarize/select-index.js +3 -1
- package/lib/cjs/hooks/use-state.js +181 -80
- package/lib/cjs/index.js +24 -3
- package/lib/cjs/store/types.d.ts +4 -4
- package/lib/cjs/types.d.ts +21 -1
- package/lib/cjs/utils/transformSql.js +51 -38
- package/lib/cjs/utils.d.ts +1 -0
- package/lib/cjs/utils.js +291 -56
- package/lib/es/components/dialog/formula-list/LogicGroup.d.ts +8 -5
- package/lib/es/components/dialog/formula-list/LogicGroup.js +65 -19
- package/lib/es/components/dialog/formula-list/index.js +373 -152
- package/lib/es/components/dialog/formula-list/index.less +18 -5
- package/lib/es/components/dialog/formula-list/utils.js +45 -17
- package/lib/es/components/dialog/select-summarize/index.js +7 -0
- package/lib/es/components/modules/summarize/group-by.js +10 -1
- package/lib/es/components/modules/summarize/select-index.js +3 -1
- package/lib/es/hooks/use-state.js +182 -81
- package/lib/es/index.js +25 -4
- package/lib/es/store/types.d.ts +4 -4
- package/lib/es/types.d.ts +21 -1
- package/lib/es/utils/transformSql.js +52 -39
- package/lib/es/utils.d.ts +1 -0
- package/lib/es/utils.js +290 -55
- package/package.json +1 -1
package/lib/cjs/index.js
CHANGED
|
@@ -29,6 +29,8 @@ var SqlVisionBuilder = _react["default"].forwardRef(function (props, ref) {
|
|
|
29
29
|
getColumns = props.getColumns,
|
|
30
30
|
onChange = props.onChange,
|
|
31
31
|
getModuleDiffCode = props.getModuleDiffCode,
|
|
32
|
+
getFormulaSqlCode = props.getFormulaSqlCode,
|
|
33
|
+
getFormulaDiffCode = props.getFormulaDiffCode,
|
|
32
34
|
getExistsError = props.getExistsError,
|
|
33
35
|
_props$tableNameTpl = props.tableNameTpl,
|
|
34
36
|
tableNameTpl = _props$tableNameTpl === void 0 ? '${name}' : _props$tableNameTpl,
|
|
@@ -75,6 +77,10 @@ var SqlVisionBuilder = _react["default"].forwardRef(function (props, ref) {
|
|
|
75
77
|
moduleDiff = _props$moduleDiff === void 0 ? false : _props$moduleDiff,
|
|
76
78
|
_props$moduleCopy = props.moduleCopy,
|
|
77
79
|
moduleCopy = _props$moduleCopy === void 0 ? false : _props$moduleCopy,
|
|
80
|
+
_props$showFormulaSql = props.showFormulaSql,
|
|
81
|
+
showFormulaSql = _props$showFormulaSql === void 0 ? true : _props$showFormulaSql,
|
|
82
|
+
_props$showFormulaDif = props.showFormulaDiff,
|
|
83
|
+
showFormulaDiff = _props$showFormulaDif === void 0 ? true : _props$showFormulaDif,
|
|
78
84
|
_props$joinAliasConfl = props.joinAliasConflictCheck,
|
|
79
85
|
joinAliasConflictCheck = _props$joinAliasConfl === void 0 ? false : _props$joinAliasConfl,
|
|
80
86
|
_props$operatorList = props.operatorList,
|
|
@@ -85,13 +91,19 @@ var SqlVisionBuilder = _react["default"].forwardRef(function (props, ref) {
|
|
|
85
91
|
getColumns && store.setFetchColumnsFn(getColumns);
|
|
86
92
|
onChange && store.setFetchChangeFn(onChange);
|
|
87
93
|
getModuleDiffCode && store.setFetchDiffFn(getModuleDiffCode);
|
|
94
|
+
store.setFetchFormulaSqlFn(getFormulaSqlCode);
|
|
95
|
+
store.setFetchFormulaDiffFn(getFormulaDiffCode);
|
|
88
96
|
}, []);
|
|
97
|
+
(0, _react.useEffect)(function () {
|
|
98
|
+
store.setFetchFormulaSqlFn(getFormulaSqlCode);
|
|
99
|
+
store.setFetchFormulaDiffFn(getFormulaDiffCode);
|
|
100
|
+
}, [getFormulaSqlCode, getFormulaDiffCode]);
|
|
89
101
|
(0, _react.useEffect)(function () {
|
|
90
102
|
store.setProps(props);
|
|
91
103
|
}, [props]);
|
|
92
104
|
(0, _react.useEffect)(function () {
|
|
93
|
-
var
|
|
94
|
-
var
|
|
105
|
+
var source_value = (0, _utils.normalizeAndOrStructure)((0, _utils.patchData)(value, constantList, formulaTemplates));
|
|
106
|
+
var _value = (0, _utils.reassembleByUnion)(source_value);
|
|
95
107
|
store.setPreData((0, _cloneDeep["default"])(_value), isSubquery, isExit);
|
|
96
108
|
store.setSourceData(source_value);
|
|
97
109
|
getExistsError && store.setExistsErrorFn(getExistsError, value);
|
|
@@ -119,15 +131,24 @@ var SqlVisionBuilder = _react["default"].forwardRef(function (props, ref) {
|
|
|
119
131
|
store.setCopyType(copyType || []);
|
|
120
132
|
store.setMetabaseCopy(metabaseCopy);
|
|
121
133
|
store.setModuleDiff(moduleDiff);
|
|
134
|
+
store.setShowFormulaSql(showFormulaSql);
|
|
135
|
+
store.setShowFormulaDiff(showFormulaDiff);
|
|
122
136
|
store.setIsSubquery(isSubquery);
|
|
123
137
|
store.setModuleCopy(moduleCopy);
|
|
124
138
|
store.setJoinAliasConflictCheck(joinAliasConflictCheck);
|
|
125
139
|
store.setOperatorList(operatorList || []);
|
|
126
|
-
}, [showFields, fieldNameTpl, tableNameTpl, toolbar, showSubquery, subShowSubquery, constantList, formulaTemplates, ignoreGroupByType, filterCustomType, isExit, tableEnableAlias, fieldEnableAlias, groupByEnableAlias, isSelectFields, tableFlat, copyType, metabaseCopy, moduleDiff, isSubquery, moduleCopy, joinAliasConflictCheck, operatorList]);
|
|
140
|
+
}, [showFields, fieldNameTpl, tableNameTpl, toolbar, showSubquery, subShowSubquery, constantList, formulaTemplates, ignoreGroupByType, filterCustomType, isExit, tableEnableAlias, fieldEnableAlias, groupByEnableAlias, isSelectFields, tableFlat, copyType, metabaseCopy, moduleDiff, showFormulaSql, showFormulaDiff, getFormulaSqlCode, getFormulaDiffCode, isSubquery, moduleCopy, joinAliasConflictCheck, operatorList]);
|
|
127
141
|
_react["default"].useImperativeHandle(ref, function () {
|
|
128
142
|
return {
|
|
129
143
|
reset: function reset() {
|
|
130
144
|
store.reset();
|
|
145
|
+
},
|
|
146
|
+
getConfig: function getConfig() {
|
|
147
|
+
var metaList = (0, _utils.normalizeLegacySummarizeForSave)((0, _utils.splitByUnion)(store.getCurrentMetaList()));
|
|
148
|
+
if (metaList[0]) {
|
|
149
|
+
metaList[0].patchVersion = '1.1.0';
|
|
150
|
+
}
|
|
151
|
+
return metaList;
|
|
131
152
|
}
|
|
132
153
|
};
|
|
133
154
|
});
|
package/lib/cjs/store/types.d.ts
CHANGED
|
@@ -97,10 +97,10 @@ export interface AtomsCaseWhen {
|
|
|
97
97
|
type: AtomsTypeEnum.CASE_WHEN;
|
|
98
98
|
}
|
|
99
99
|
export interface AtomsAndOr {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
100
|
+
items: {
|
|
101
|
+
operator?: 'and' | 'or';
|
|
102
|
+
atoms: AtomsItem[];
|
|
103
|
+
}[];
|
|
104
104
|
quotes: string;
|
|
105
105
|
type: AtomsTypeEnum.AND_OR;
|
|
106
106
|
}
|
package/lib/cjs/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { MetaListType, ToolbarType, FormulaTemplatesItem, ChangeType, FormulaTypeEnum } from './store/types';
|
|
1
|
+
import type { MetaListType, ToolbarType, FormulaTemplatesItem, ChangeType, FormulaTypeEnum, AtomsItem } from './store/types';
|
|
2
2
|
import { UnionEnum } from './store/enum';
|
|
3
3
|
import { DataType } from './components/dialog/select-join-column';
|
|
4
4
|
export interface MetaListProps {
|
|
@@ -11,6 +11,21 @@ export interface MetaListProps {
|
|
|
11
11
|
export interface FetchOptions {
|
|
12
12
|
isExit: boolean;
|
|
13
13
|
}
|
|
14
|
+
export type FormulaSqlCodeResult = string | {
|
|
15
|
+
sql?: string;
|
|
16
|
+
code?: string;
|
|
17
|
+
[key: string]: any;
|
|
18
|
+
};
|
|
19
|
+
export type FormulaDiffCodeResult = string | {
|
|
20
|
+
oldCode?: string;
|
|
21
|
+
newCode?: string;
|
|
22
|
+
code?: string;
|
|
23
|
+
[key: string]: any;
|
|
24
|
+
};
|
|
25
|
+
export interface FormulaDiffCodeParams {
|
|
26
|
+
oldValue: AtomsItem[];
|
|
27
|
+
newValue: AtomsItem[];
|
|
28
|
+
}
|
|
14
29
|
export interface MetabaseProps {
|
|
15
30
|
loading?: boolean;
|
|
16
31
|
btnText?: string;
|
|
@@ -52,6 +67,8 @@ export interface MetabaseProps {
|
|
|
52
67
|
metabaseCopy?: boolean;
|
|
53
68
|
moduleDiff?: boolean;
|
|
54
69
|
moduleCopy?: boolean;
|
|
70
|
+
showFormulaSql?: boolean;
|
|
71
|
+
showFormulaDiff?: boolean;
|
|
55
72
|
joinAliasConflictCheck?: boolean;
|
|
56
73
|
getModuleDiffCode?: (obj: {
|
|
57
74
|
oldCode: MetaListType;
|
|
@@ -60,6 +77,8 @@ export interface MetabaseProps {
|
|
|
60
77
|
oldCode: string;
|
|
61
78
|
newCode: string;
|
|
62
79
|
}>;
|
|
80
|
+
getFormulaSqlCode?: (value: AtomsItem[]) => Promise<FormulaSqlCodeResult> | FormulaSqlCodeResult;
|
|
81
|
+
getFormulaDiffCode?: (params: FormulaDiffCodeParams) => Promise<FormulaDiffCodeResult> | FormulaDiffCodeResult;
|
|
63
82
|
getExistsError?: (params: MetaListType[]) => Promise<any[]>;
|
|
64
83
|
operatorList?: any[];
|
|
65
84
|
otherTypes?: any[];
|
|
@@ -76,4 +95,5 @@ export interface DatasourceType {
|
|
|
76
95
|
}
|
|
77
96
|
export interface SqlVisionBuilderRef {
|
|
78
97
|
reset: () => void;
|
|
98
|
+
getConfig: () => MetaListType[];
|
|
79
99
|
}
|
|
@@ -6,8 +6,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.transformSql = exports.handleBaseType2Sql = void 0;
|
|
8
8
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/toConsumableArray"));
|
|
9
|
-
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/objectSpread2"));
|
|
10
9
|
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/objectWithoutProperties"));
|
|
10
|
+
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/objectSpread2"));
|
|
11
11
|
var _excluded = ["children"];
|
|
12
12
|
var procEnum = {
|
|
13
13
|
mysql: 'mysql',
|
|
@@ -55,6 +55,28 @@ var SQL_COLUMN_TYPE = {
|
|
|
55
55
|
LONG: 'LONG',
|
|
56
56
|
CURRENCY: 'CURRENCY'
|
|
57
57
|
};
|
|
58
|
+
var normalizeAndOrItems = function normalizeAndOrItems(item) {
|
|
59
|
+
if (Array.isArray(item.items) && item.items.length > 0) {
|
|
60
|
+
return item.items.map(function (logicItem, index) {
|
|
61
|
+
return (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, index > 0 ? {
|
|
62
|
+
operator: logicItem.operator || item.operator || 'and'
|
|
63
|
+
} : {}), {}, {
|
|
64
|
+
atoms: Array.isArray(logicItem.atoms) ? logicItem.atoms : []
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
if (Array.isArray(item.leftAtoms) || Array.isArray(item.rightAtoms)) {
|
|
69
|
+
return [{
|
|
70
|
+
atoms: Array.isArray(item.leftAtoms) ? item.leftAtoms : []
|
|
71
|
+
}, {
|
|
72
|
+
operator: item.operator || 'and',
|
|
73
|
+
atoms: Array.isArray(item.rightAtoms) ? item.rightAtoms : []
|
|
74
|
+
}];
|
|
75
|
+
}
|
|
76
|
+
return [{
|
|
77
|
+
atoms: Array.isArray(item.atoms) ? item.atoms : []
|
|
78
|
+
}];
|
|
79
|
+
};
|
|
58
80
|
var DATE_GROUP = [SQL_COLUMN_TYPE.DATE];
|
|
59
81
|
var NUMBER_GROUP = [SQL_COLUMN_TYPE.FLOAT, SQL_COLUMN_TYPE.LONG, SQL_COLUMN_TYPE.CURRENCY];
|
|
60
82
|
var STRING_GROUP = [SQL_COLUMN_TYPE.STRING];
|
|
@@ -73,7 +95,7 @@ var _recursionArr2 = function _recursionArr(arr) {
|
|
|
73
95
|
}
|
|
74
96
|
return obj;
|
|
75
97
|
};
|
|
76
|
-
var
|
|
98
|
+
var _handleBaseType2Sql9 = exports.handleBaseType2Sql = function handleBaseType2Sql(list) {
|
|
77
99
|
var db = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : procEnum.mysql;
|
|
78
100
|
var sql = '';
|
|
79
101
|
var constants = [];
|
|
@@ -135,11 +157,11 @@ var _handleBaseType2Sql1 = exports.handleBaseType2Sql = function handleBaseType2
|
|
|
135
157
|
if (type === BlockTypeEnum.joinDefault) {
|
|
136
158
|
var lhs = item.lhs,
|
|
137
159
|
rhs = item.rhs;
|
|
138
|
-
var _handleBaseType2Sql =
|
|
160
|
+
var _handleBaseType2Sql = _handleBaseType2Sql9(lhs, db),
|
|
139
161
|
leftSql = _handleBaseType2Sql.sql,
|
|
140
162
|
leftSqlItems = _handleBaseType2Sql.sql_items,
|
|
141
163
|
joinDefaultLeftConstants = _handleBaseType2Sql.constants;
|
|
142
|
-
var _handleBaseType2Sql2 =
|
|
164
|
+
var _handleBaseType2Sql2 = _handleBaseType2Sql9(rhs, db),
|
|
143
165
|
rightSql = _handleBaseType2Sql2.sql,
|
|
144
166
|
rightSqlItems = _handleBaseType2Sql2.sql_items,
|
|
145
167
|
joinDefaultRightConstants = _handleBaseType2Sql2.constants;
|
|
@@ -177,11 +199,11 @@ var _handleBaseType2Sql1 = exports.handleBaseType2Sql = function handleBaseType2
|
|
|
177
199
|
condition = item.condition,
|
|
178
200
|
database_type = item.database_type,
|
|
179
201
|
formula = item.formula;
|
|
180
|
-
var _handleBaseType2Sql3 =
|
|
202
|
+
var _handleBaseType2Sql3 = _handleBaseType2Sql9(_lhs, db),
|
|
181
203
|
_leftSql = _handleBaseType2Sql3.sql,
|
|
182
204
|
_leftSqlItems = _handleBaseType2Sql3.sql_items,
|
|
183
205
|
_joinDefaultLeftConstants = _handleBaseType2Sql3.constants;
|
|
184
|
-
var _handleBaseType2Sql4 =
|
|
206
|
+
var _handleBaseType2Sql4 = _handleBaseType2Sql9(_rhs, db),
|
|
185
207
|
_rightSql = _handleBaseType2Sql4.sql,
|
|
186
208
|
_rightSqlItems = _handleBaseType2Sql4.sql_items,
|
|
187
209
|
_joinDefaultRightConstants = _handleBaseType2Sql4.constants;
|
|
@@ -453,13 +475,13 @@ var _handleBaseType2Sql1 = exports.handleBaseType2Sql = function handleBaseType2
|
|
|
453
475
|
if (type === BlockTypeEnum.FORMULA) {
|
|
454
476
|
var argSqlList = (Array.isArray(item.args) ? item.args : []).map(function (arg) {
|
|
455
477
|
if ((arg === null || arg === void 0 ? void 0 : arg.type) === BlockTypeEnum.collection) {
|
|
456
|
-
var _handleBaseType2Sql5 =
|
|
478
|
+
var _handleBaseType2Sql5 = _handleBaseType2Sql9(arg.list, db),
|
|
457
479
|
collectionSql = _handleBaseType2Sql5.sql,
|
|
458
480
|
collectionConstants = _handleBaseType2Sql5.constants;
|
|
459
481
|
constants.push.apply(constants, (0, _toConsumableArray2["default"])(collectionConstants));
|
|
460
482
|
return collectionSql.trim();
|
|
461
483
|
}
|
|
462
|
-
var _handleBaseType2Sql6 =
|
|
484
|
+
var _handleBaseType2Sql6 = _handleBaseType2Sql9([arg], db),
|
|
463
485
|
nestedSql = _handleBaseType2Sql6.sql,
|
|
464
486
|
nestedConstants = _handleBaseType2Sql6.constants;
|
|
465
487
|
constants.push.apply(constants, (0, _toConsumableArray2["default"])(nestedConstants));
|
|
@@ -468,31 +490,22 @@ var _handleBaseType2Sql1 = exports.handleBaseType2Sql = function handleBaseType2
|
|
|
468
490
|
sql += " ".concat(item.name, "(").concat(argSqlList.join(', '), ")");
|
|
469
491
|
}
|
|
470
492
|
if (type === BlockTypeEnum.collection) {
|
|
471
|
-
var _handleBaseType2Sql7 =
|
|
493
|
+
var _handleBaseType2Sql7 = _handleBaseType2Sql9(item.list, db),
|
|
472
494
|
collectionSql = _handleBaseType2Sql7.sql,
|
|
473
495
|
collectionConstants = _handleBaseType2Sql7.constants;
|
|
474
496
|
sql += " ".concat(collectionSql);
|
|
475
497
|
constants.push.apply(constants, (0, _toConsumableArray2["default"])(collectionConstants));
|
|
476
498
|
}
|
|
477
499
|
if (type === BlockTypeEnum.andOr) {
|
|
478
|
-
var
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
leftConstants = _handleBaseType2Sql8.constants;
|
|
483
|
-
var _handleBaseType2Sql9 = _handleBaseType2Sql1(item.rightAtoms || [], db),
|
|
484
|
-
_rightSql2 = _handleBaseType2Sql9.sql,
|
|
485
|
-
rightConstants = _handleBaseType2Sql9.constants;
|
|
486
|
-
constants.push.apply(constants, (0, _toConsumableArray2["default"])(leftConstants).concat((0, _toConsumableArray2["default"])(rightConstants)));
|
|
487
|
-
var operator = (item.operator || 'and').toUpperCase();
|
|
488
|
-
sql += " (".concat(_leftSql2.trim(), " ").concat(operator, " ").concat(_rightSql2.trim(), ")");
|
|
489
|
-
} else {
|
|
490
|
-
var _handleBaseType2Sql0 = _handleBaseType2Sql1(item.atoms || [], db),
|
|
491
|
-
atomsSql = _handleBaseType2Sql0.sql,
|
|
492
|
-
nestedConstants = _handleBaseType2Sql0.constants;
|
|
500
|
+
var itemsSql = normalizeAndOrItems(item).map(function (logicItem, index) {
|
|
501
|
+
var _handleBaseType2Sql8 = _handleBaseType2Sql9(logicItem.atoms || [], db),
|
|
502
|
+
atomsSql = _handleBaseType2Sql8.sql,
|
|
503
|
+
nestedConstants = _handleBaseType2Sql8.constants;
|
|
493
504
|
constants.push.apply(constants, (0, _toConsumableArray2["default"])(nestedConstants));
|
|
494
|
-
|
|
495
|
-
|
|
505
|
+
var trimmedSql = atomsSql.trim();
|
|
506
|
+
return index === 0 ? trimmedSql : "".concat((logicItem.operator || 'and').toUpperCase(), " ").concat(trimmedSql);
|
|
507
|
+
}).filter(Boolean).join(' ');
|
|
508
|
+
sql += " (".concat(itemsSql, ")");
|
|
496
509
|
}
|
|
497
510
|
});
|
|
498
511
|
return {
|
|
@@ -514,9 +527,9 @@ var _handleJoinData = function _handleJoinData(joinData) {
|
|
|
514
527
|
if (isSubquery) {
|
|
515
528
|
subQuery = subquery;
|
|
516
529
|
}
|
|
517
|
-
var
|
|
518
|
-
sql =
|
|
519
|
-
joinConstants =
|
|
530
|
+
var _handleBaseType2Sql0 = _handleBaseType2Sql9(expressions, db),
|
|
531
|
+
sql = _handleBaseType2Sql0.sql,
|
|
532
|
+
joinConstants = _handleBaseType2Sql0.constants;
|
|
520
533
|
var joinCondition = "on ".concat(sql);
|
|
521
534
|
constants = joinConstants;
|
|
522
535
|
return {
|
|
@@ -599,9 +612,9 @@ var _handleNesting = function handleNesting(data) {
|
|
|
599
612
|
var customColumnsConstants = [];
|
|
600
613
|
var handleCustomColumn = function handleCustomColumn(data) {
|
|
601
614
|
return data.map(function (it) {
|
|
602
|
-
var
|
|
603
|
-
field_sql =
|
|
604
|
-
constants =
|
|
615
|
+
var _handleBaseType2Sql1 = _handleBaseType2Sql9(it.formulaList, db),
|
|
616
|
+
field_sql = _handleBaseType2Sql1.sql,
|
|
617
|
+
constants = _handleBaseType2Sql1.constants;
|
|
605
618
|
customColumnsConstants.push.apply(customColumnsConstants, (0, _toConsumableArray2["default"])(constants));
|
|
606
619
|
return {
|
|
607
620
|
field_sql: "".concat(field_sql, " as ").concat(it.name),
|
|
@@ -616,9 +629,9 @@ var _handleNesting = function handleNesting(data) {
|
|
|
616
629
|
obj.customColumnsConstants = customColumnsConstants;
|
|
617
630
|
}
|
|
618
631
|
if (filterData && filterData.filter.length) {
|
|
619
|
-
var
|
|
620
|
-
sql =
|
|
621
|
-
constants =
|
|
632
|
+
var _handleBaseType2Sql10 = _handleBaseType2Sql9(filterData.filter, db),
|
|
633
|
+
sql = _handleBaseType2Sql10.sql,
|
|
634
|
+
constants = _handleBaseType2Sql10.constants;
|
|
622
635
|
obj.filters = 'WHERE ' + sql;
|
|
623
636
|
obj.filtersConstants = constants;
|
|
624
637
|
}
|
|
@@ -643,7 +656,7 @@ var _handleNesting = function handleNesting(data) {
|
|
|
643
656
|
if (summarize.by.length) {
|
|
644
657
|
obj.groupBy.groupColumns = summarize.by.map(function (v) {
|
|
645
658
|
var _v$atoms;
|
|
646
|
-
var fieldSql = (_v$atoms = v.atoms) !== null && _v$atoms !== void 0 && _v$atoms.length ?
|
|
659
|
+
var fieldSql = (_v$atoms = v.atoms) !== null && _v$atoms !== void 0 && _v$atoms.length ? _handleBaseType2Sql9(v.atoms, db).sql.trim() || v.sql : v.sql || "".concat(v.alias, ".").concat(v.realName || v.name);
|
|
647
660
|
queryColumns.push({
|
|
648
661
|
field_sql: "".concat(fieldSql, " as ").concat(v.fieldAlias),
|
|
649
662
|
read_name: '',
|
|
@@ -661,8 +674,8 @@ var _handleNesting = function handleNesting(data) {
|
|
|
661
674
|
}
|
|
662
675
|
if (sortData && sortData.sort.length) {
|
|
663
676
|
obj.orderInfos = "ORDER BY ".concat(sortData.sort.map(function (v) {
|
|
664
|
-
var
|
|
665
|
-
sql =
|
|
677
|
+
var _handleBaseType2Sql11 = _handleBaseType2Sql9(v.expression, db),
|
|
678
|
+
sql = _handleBaseType2Sql11.sql;
|
|
666
679
|
return "".concat(sql, " ").concat(v.sort);
|
|
667
680
|
}).join(', '));
|
|
668
681
|
}
|
package/lib/cjs/utils.d.ts
CHANGED
|
@@ -25,6 +25,7 @@ export declare const getHelper: (list: MetaListType[], item: MetaListType) => He
|
|
|
25
25
|
export declare const mergeSubQueryColumns: (columns: MetaData_ColumnsType[], oldColumns?: MetaData_ColumnsType[], isSelectFields?: boolean) => MetaData_ColumnsType[];
|
|
26
26
|
export declare const syncSubQueryFieldReferences: (list: MetaListType[], table: MetaData_TableType, columns: MetaData_ColumnsType[], oldColumns?: MetaData_ColumnsType[]) => MetaListType[];
|
|
27
27
|
export declare const getSubColumns: (metaList: any) => DataType[];
|
|
28
|
+
export declare const normalizeAndOrStructure: <T>(data: T) => T;
|
|
28
29
|
export declare function isValidSQLAlias(str: string): boolean;
|
|
29
30
|
export declare const changeTableAlias: (list: MetaListType[] | [], curObj: Pick<MetaData_TableType, "tableUuid" | "alias">) => MetaListType[];
|
|
30
31
|
export declare const changeFieldAlias: (list: MetaListType[], curObj: Pick<MetaData_ColumnsType, "fieldUuid" | "fieldAlias"> & Partial<Pick<MetaData_ColumnsType, "id" | "name" | "datasourceId">> & Partial<Pick<MetaSummarize_Group | MetaSummarize_By, "table" | "tableId" | "tableUuid" | "fieldId" | "name">>) => MetaListType[];
|