@gingkoo/pandora-metabase 1.0.141 → 1.0.143
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/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-column/index.js +5 -2
- 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 +167 -75
- package/lib/cjs/index.js +17 -3
- package/lib/cjs/store/types.d.ts +4 -4
- package/lib/cjs/types.d.ts +20 -1
- package/lib/cjs/utils/transformSql.js +51 -38
- package/lib/cjs/utils.d.ts +1 -0
- package/lib/cjs/utils.js +327 -57
- 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-column/index.js +5 -2
- 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 +167 -75
- package/lib/es/index.js +18 -4
- package/lib/es/store/types.d.ts +4 -4
- package/lib/es/types.d.ts +20 -1
- package/lib/es/utils/transformSql.js +52 -39
- package/lib/es/utils.d.ts +1 -0
- package/lib/es/utils.js +326 -56
- package/package.json +1 -1
package/lib/es/index.js
CHANGED
|
@@ -8,7 +8,7 @@ import './locale/zh';
|
|
|
8
8
|
import { __ } from './locale';
|
|
9
9
|
import Loading from './common/Loading';
|
|
10
10
|
import Metabase from './components/metabase';
|
|
11
|
-
import { reassembleByUnion, patchData, splitByUnion, normalizeLegacySummarizeForSave } from './utils';
|
|
11
|
+
import { reassembleByUnion, patchData, splitByUnion, normalizeLegacySummarizeForSave, normalizeAndOrStructure } from './utils';
|
|
12
12
|
import cloneDeep from 'lodash/cloneDeep';
|
|
13
13
|
var EMPTY_ARRAY = [];
|
|
14
14
|
var SqlVisionBuilder = React.forwardRef(function (props, ref) {
|
|
@@ -20,6 +20,8 @@ var SqlVisionBuilder = React.forwardRef(function (props, ref) {
|
|
|
20
20
|
getColumns = props.getColumns,
|
|
21
21
|
onChange = props.onChange,
|
|
22
22
|
getModuleDiffCode = props.getModuleDiffCode,
|
|
23
|
+
getFormulaSqlCode = props.getFormulaSqlCode,
|
|
24
|
+
getFormulaDiffCode = props.getFormulaDiffCode,
|
|
23
25
|
getExistsError = props.getExistsError,
|
|
24
26
|
_props$tableNameTpl = props.tableNameTpl,
|
|
25
27
|
tableNameTpl = _props$tableNameTpl === void 0 ? '${name}' : _props$tableNameTpl,
|
|
@@ -66,6 +68,10 @@ var SqlVisionBuilder = React.forwardRef(function (props, ref) {
|
|
|
66
68
|
moduleDiff = _props$moduleDiff === void 0 ? false : _props$moduleDiff,
|
|
67
69
|
_props$moduleCopy = props.moduleCopy,
|
|
68
70
|
moduleCopy = _props$moduleCopy === void 0 ? false : _props$moduleCopy,
|
|
71
|
+
_props$showFormulaSql = props.showFormulaSql,
|
|
72
|
+
showFormulaSql = _props$showFormulaSql === void 0 ? true : _props$showFormulaSql,
|
|
73
|
+
_props$showFormulaDif = props.showFormulaDiff,
|
|
74
|
+
showFormulaDiff = _props$showFormulaDif === void 0 ? true : _props$showFormulaDif,
|
|
69
75
|
_props$joinAliasConfl = props.joinAliasConflictCheck,
|
|
70
76
|
joinAliasConflictCheck = _props$joinAliasConfl === void 0 ? false : _props$joinAliasConfl,
|
|
71
77
|
_props$operatorList = props.operatorList,
|
|
@@ -76,13 +82,19 @@ var SqlVisionBuilder = React.forwardRef(function (props, ref) {
|
|
|
76
82
|
getColumns && store.setFetchColumnsFn(getColumns);
|
|
77
83
|
onChange && store.setFetchChangeFn(onChange);
|
|
78
84
|
getModuleDiffCode && store.setFetchDiffFn(getModuleDiffCode);
|
|
85
|
+
store.setFetchFormulaSqlFn(getFormulaSqlCode);
|
|
86
|
+
store.setFetchFormulaDiffFn(getFormulaDiffCode);
|
|
79
87
|
}, []);
|
|
88
|
+
useEffect(function () {
|
|
89
|
+
store.setFetchFormulaSqlFn(getFormulaSqlCode);
|
|
90
|
+
store.setFetchFormulaDiffFn(getFormulaDiffCode);
|
|
91
|
+
}, [getFormulaSqlCode, getFormulaDiffCode]);
|
|
80
92
|
useEffect(function () {
|
|
81
93
|
store.setProps(props);
|
|
82
94
|
}, [props]);
|
|
83
95
|
useEffect(function () {
|
|
84
|
-
var
|
|
85
|
-
var
|
|
96
|
+
var source_value = normalizeAndOrStructure(patchData(value, constantList, formulaTemplates));
|
|
97
|
+
var _value = reassembleByUnion(source_value);
|
|
86
98
|
store.setPreData(cloneDeep(_value), isSubquery, isExit);
|
|
87
99
|
store.setSourceData(source_value);
|
|
88
100
|
getExistsError && store.setExistsErrorFn(getExistsError, value);
|
|
@@ -110,11 +122,13 @@ var SqlVisionBuilder = React.forwardRef(function (props, ref) {
|
|
|
110
122
|
store.setCopyType(copyType || []);
|
|
111
123
|
store.setMetabaseCopy(metabaseCopy);
|
|
112
124
|
store.setModuleDiff(moduleDiff);
|
|
125
|
+
store.setShowFormulaSql(showFormulaSql);
|
|
126
|
+
store.setShowFormulaDiff(showFormulaDiff);
|
|
113
127
|
store.setIsSubquery(isSubquery);
|
|
114
128
|
store.setModuleCopy(moduleCopy);
|
|
115
129
|
store.setJoinAliasConflictCheck(joinAliasConflictCheck);
|
|
116
130
|
store.setOperatorList(operatorList || []);
|
|
117
|
-
}, [showFields, fieldNameTpl, tableNameTpl, toolbar, showSubquery, subShowSubquery, constantList, formulaTemplates, ignoreGroupByType, filterCustomType, isExit, tableEnableAlias, fieldEnableAlias, groupByEnableAlias, isSelectFields, tableFlat, copyType, metabaseCopy, moduleDiff, isSubquery, moduleCopy, joinAliasConflictCheck, operatorList]);
|
|
131
|
+
}, [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]);
|
|
118
132
|
React.useImperativeHandle(ref, function () {
|
|
119
133
|
return {
|
|
120
134
|
reset: function reset() {
|
package/lib/es/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/es/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
|
+
oldCode: AtomsItem[];
|
|
27
|
+
newCode: 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[];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
2
|
-
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
3
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
3
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
4
4
|
var _excluded = ["children"];
|
|
5
5
|
var procEnum = {
|
|
6
6
|
mysql: 'mysql',
|
|
@@ -48,6 +48,28 @@ var SQL_COLUMN_TYPE = {
|
|
|
48
48
|
LONG: 'LONG',
|
|
49
49
|
CURRENCY: 'CURRENCY'
|
|
50
50
|
};
|
|
51
|
+
var normalizeAndOrItems = function normalizeAndOrItems(item) {
|
|
52
|
+
if (Array.isArray(item.items) && item.items.length > 0) {
|
|
53
|
+
return item.items.map(function (logicItem, index) {
|
|
54
|
+
return _objectSpread(_objectSpread({}, index > 0 ? {
|
|
55
|
+
operator: logicItem.operator || item.operator || 'and'
|
|
56
|
+
} : {}), {}, {
|
|
57
|
+
atoms: Array.isArray(logicItem.atoms) ? logicItem.atoms : []
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
if (Array.isArray(item.leftAtoms) || Array.isArray(item.rightAtoms)) {
|
|
62
|
+
return [{
|
|
63
|
+
atoms: Array.isArray(item.leftAtoms) ? item.leftAtoms : []
|
|
64
|
+
}, {
|
|
65
|
+
operator: item.operator || 'and',
|
|
66
|
+
atoms: Array.isArray(item.rightAtoms) ? item.rightAtoms : []
|
|
67
|
+
}];
|
|
68
|
+
}
|
|
69
|
+
return [{
|
|
70
|
+
atoms: Array.isArray(item.atoms) ? item.atoms : []
|
|
71
|
+
}];
|
|
72
|
+
};
|
|
51
73
|
var DATE_GROUP = [SQL_COLUMN_TYPE.DATE];
|
|
52
74
|
var NUMBER_GROUP = [SQL_COLUMN_TYPE.FLOAT, SQL_COLUMN_TYPE.LONG, SQL_COLUMN_TYPE.CURRENCY];
|
|
53
75
|
var STRING_GROUP = [SQL_COLUMN_TYPE.STRING];
|
|
@@ -66,7 +88,7 @@ var _recursionArr2 = function _recursionArr(arr) {
|
|
|
66
88
|
}
|
|
67
89
|
return obj;
|
|
68
90
|
};
|
|
69
|
-
var
|
|
91
|
+
var _handleBaseType2Sql9 = function handleBaseType2Sql(list) {
|
|
70
92
|
var db = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : procEnum.mysql;
|
|
71
93
|
var sql = '';
|
|
72
94
|
var constants = [];
|
|
@@ -128,11 +150,11 @@ var _handleBaseType2Sql1 = function handleBaseType2Sql(list) {
|
|
|
128
150
|
if (type === BlockTypeEnum.joinDefault) {
|
|
129
151
|
var lhs = item.lhs,
|
|
130
152
|
rhs = item.rhs;
|
|
131
|
-
var _handleBaseType2Sql =
|
|
153
|
+
var _handleBaseType2Sql = _handleBaseType2Sql9(lhs, db),
|
|
132
154
|
leftSql = _handleBaseType2Sql.sql,
|
|
133
155
|
leftSqlItems = _handleBaseType2Sql.sql_items,
|
|
134
156
|
joinDefaultLeftConstants = _handleBaseType2Sql.constants;
|
|
135
|
-
var _handleBaseType2Sql2 =
|
|
157
|
+
var _handleBaseType2Sql2 = _handleBaseType2Sql9(rhs, db),
|
|
136
158
|
rightSql = _handleBaseType2Sql2.sql,
|
|
137
159
|
rightSqlItems = _handleBaseType2Sql2.sql_items,
|
|
138
160
|
joinDefaultRightConstants = _handleBaseType2Sql2.constants;
|
|
@@ -170,11 +192,11 @@ var _handleBaseType2Sql1 = function handleBaseType2Sql(list) {
|
|
|
170
192
|
condition = item.condition,
|
|
171
193
|
database_type = item.database_type,
|
|
172
194
|
formula = item.formula;
|
|
173
|
-
var _handleBaseType2Sql3 =
|
|
195
|
+
var _handleBaseType2Sql3 = _handleBaseType2Sql9(_lhs, db),
|
|
174
196
|
_leftSql = _handleBaseType2Sql3.sql,
|
|
175
197
|
_leftSqlItems = _handleBaseType2Sql3.sql_items,
|
|
176
198
|
_joinDefaultLeftConstants = _handleBaseType2Sql3.constants;
|
|
177
|
-
var _handleBaseType2Sql4 =
|
|
199
|
+
var _handleBaseType2Sql4 = _handleBaseType2Sql9(_rhs, db),
|
|
178
200
|
_rightSql = _handleBaseType2Sql4.sql,
|
|
179
201
|
_rightSqlItems = _handleBaseType2Sql4.sql_items,
|
|
180
202
|
_joinDefaultRightConstants = _handleBaseType2Sql4.constants;
|
|
@@ -446,13 +468,13 @@ var _handleBaseType2Sql1 = function handleBaseType2Sql(list) {
|
|
|
446
468
|
if (type === BlockTypeEnum.FORMULA) {
|
|
447
469
|
var argSqlList = (Array.isArray(item.args) ? item.args : []).map(function (arg) {
|
|
448
470
|
if ((arg === null || arg === void 0 ? void 0 : arg.type) === BlockTypeEnum.collection) {
|
|
449
|
-
var _handleBaseType2Sql5 =
|
|
471
|
+
var _handleBaseType2Sql5 = _handleBaseType2Sql9(arg.list, db),
|
|
450
472
|
collectionSql = _handleBaseType2Sql5.sql,
|
|
451
473
|
collectionConstants = _handleBaseType2Sql5.constants;
|
|
452
474
|
constants.push.apply(constants, _toConsumableArray(collectionConstants));
|
|
453
475
|
return collectionSql.trim();
|
|
454
476
|
}
|
|
455
|
-
var _handleBaseType2Sql6 =
|
|
477
|
+
var _handleBaseType2Sql6 = _handleBaseType2Sql9([arg], db),
|
|
456
478
|
nestedSql = _handleBaseType2Sql6.sql,
|
|
457
479
|
nestedConstants = _handleBaseType2Sql6.constants;
|
|
458
480
|
constants.push.apply(constants, _toConsumableArray(nestedConstants));
|
|
@@ -461,31 +483,22 @@ var _handleBaseType2Sql1 = function handleBaseType2Sql(list) {
|
|
|
461
483
|
sql += " ".concat(item.name, "(").concat(argSqlList.join(', '), ")");
|
|
462
484
|
}
|
|
463
485
|
if (type === BlockTypeEnum.collection) {
|
|
464
|
-
var _handleBaseType2Sql7 =
|
|
486
|
+
var _handleBaseType2Sql7 = _handleBaseType2Sql9(item.list, db),
|
|
465
487
|
collectionSql = _handleBaseType2Sql7.sql,
|
|
466
488
|
collectionConstants = _handleBaseType2Sql7.constants;
|
|
467
489
|
sql += " ".concat(collectionSql);
|
|
468
490
|
constants.push.apply(constants, _toConsumableArray(collectionConstants));
|
|
469
491
|
}
|
|
470
492
|
if (type === BlockTypeEnum.andOr) {
|
|
471
|
-
var
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
leftConstants = _handleBaseType2Sql8.constants;
|
|
476
|
-
var _handleBaseType2Sql9 = _handleBaseType2Sql1(item.rightAtoms || [], db),
|
|
477
|
-
_rightSql2 = _handleBaseType2Sql9.sql,
|
|
478
|
-
rightConstants = _handleBaseType2Sql9.constants;
|
|
479
|
-
constants.push.apply(constants, _toConsumableArray(leftConstants).concat(_toConsumableArray(rightConstants)));
|
|
480
|
-
var operator = (item.operator || 'and').toUpperCase();
|
|
481
|
-
sql += " (".concat(_leftSql2.trim(), " ").concat(operator, " ").concat(_rightSql2.trim(), ")");
|
|
482
|
-
} else {
|
|
483
|
-
var _handleBaseType2Sql0 = _handleBaseType2Sql1(item.atoms || [], db),
|
|
484
|
-
atomsSql = _handleBaseType2Sql0.sql,
|
|
485
|
-
nestedConstants = _handleBaseType2Sql0.constants;
|
|
493
|
+
var itemsSql = normalizeAndOrItems(item).map(function (logicItem, index) {
|
|
494
|
+
var _handleBaseType2Sql8 = _handleBaseType2Sql9(logicItem.atoms || [], db),
|
|
495
|
+
atomsSql = _handleBaseType2Sql8.sql,
|
|
496
|
+
nestedConstants = _handleBaseType2Sql8.constants;
|
|
486
497
|
constants.push.apply(constants, _toConsumableArray(nestedConstants));
|
|
487
|
-
|
|
488
|
-
|
|
498
|
+
var trimmedSql = atomsSql.trim();
|
|
499
|
+
return index === 0 ? trimmedSql : "".concat((logicItem.operator || 'and').toUpperCase(), " ").concat(trimmedSql);
|
|
500
|
+
}).filter(Boolean).join(' ');
|
|
501
|
+
sql += " (".concat(itemsSql, ")");
|
|
489
502
|
}
|
|
490
503
|
});
|
|
491
504
|
return {
|
|
@@ -494,7 +507,7 @@ var _handleBaseType2Sql1 = function handleBaseType2Sql(list) {
|
|
|
494
507
|
constants: constants
|
|
495
508
|
};
|
|
496
509
|
};
|
|
497
|
-
export {
|
|
510
|
+
export { _handleBaseType2Sql9 as handleBaseType2Sql };
|
|
498
511
|
var _handleJoinData = function _handleJoinData(joinData) {
|
|
499
512
|
var db = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : procEnum.mysql;
|
|
500
513
|
var constants = [];
|
|
@@ -508,9 +521,9 @@ var _handleJoinData = function _handleJoinData(joinData) {
|
|
|
508
521
|
if (isSubquery) {
|
|
509
522
|
subQuery = subquery;
|
|
510
523
|
}
|
|
511
|
-
var
|
|
512
|
-
sql =
|
|
513
|
-
joinConstants =
|
|
524
|
+
var _handleBaseType2Sql0 = _handleBaseType2Sql9(expressions, db),
|
|
525
|
+
sql = _handleBaseType2Sql0.sql,
|
|
526
|
+
joinConstants = _handleBaseType2Sql0.constants;
|
|
514
527
|
var joinCondition = "on ".concat(sql);
|
|
515
528
|
constants = joinConstants;
|
|
516
529
|
return {
|
|
@@ -593,9 +606,9 @@ var _handleNesting = function handleNesting(data) {
|
|
|
593
606
|
var customColumnsConstants = [];
|
|
594
607
|
var handleCustomColumn = function handleCustomColumn(data) {
|
|
595
608
|
return data.map(function (it) {
|
|
596
|
-
var
|
|
597
|
-
field_sql =
|
|
598
|
-
constants =
|
|
609
|
+
var _handleBaseType2Sql1 = _handleBaseType2Sql9(it.formulaList, db),
|
|
610
|
+
field_sql = _handleBaseType2Sql1.sql,
|
|
611
|
+
constants = _handleBaseType2Sql1.constants;
|
|
599
612
|
customColumnsConstants.push.apply(customColumnsConstants, _toConsumableArray(constants));
|
|
600
613
|
return {
|
|
601
614
|
field_sql: "".concat(field_sql, " as ").concat(it.name),
|
|
@@ -610,9 +623,9 @@ var _handleNesting = function handleNesting(data) {
|
|
|
610
623
|
obj.customColumnsConstants = customColumnsConstants;
|
|
611
624
|
}
|
|
612
625
|
if (filterData && filterData.filter.length) {
|
|
613
|
-
var
|
|
614
|
-
sql =
|
|
615
|
-
constants =
|
|
626
|
+
var _handleBaseType2Sql10 = _handleBaseType2Sql9(filterData.filter, db),
|
|
627
|
+
sql = _handleBaseType2Sql10.sql,
|
|
628
|
+
constants = _handleBaseType2Sql10.constants;
|
|
616
629
|
obj.filters = 'WHERE ' + sql;
|
|
617
630
|
obj.filtersConstants = constants;
|
|
618
631
|
}
|
|
@@ -637,7 +650,7 @@ var _handleNesting = function handleNesting(data) {
|
|
|
637
650
|
if (summarize.by.length) {
|
|
638
651
|
obj.groupBy.groupColumns = summarize.by.map(function (v) {
|
|
639
652
|
var _v$atoms;
|
|
640
|
-
var fieldSql = (_v$atoms = v.atoms) !== null && _v$atoms !== void 0 && _v$atoms.length ?
|
|
653
|
+
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);
|
|
641
654
|
queryColumns.push({
|
|
642
655
|
field_sql: "".concat(fieldSql, " as ").concat(v.fieldAlias),
|
|
643
656
|
read_name: '',
|
|
@@ -655,8 +668,8 @@ var _handleNesting = function handleNesting(data) {
|
|
|
655
668
|
}
|
|
656
669
|
if (sortData && sortData.sort.length) {
|
|
657
670
|
obj.orderInfos = "ORDER BY ".concat(sortData.sort.map(function (v) {
|
|
658
|
-
var
|
|
659
|
-
sql =
|
|
671
|
+
var _handleBaseType2Sql11 = _handleBaseType2Sql9(v.expression, db),
|
|
672
|
+
sql = _handleBaseType2Sql11.sql;
|
|
660
673
|
return "".concat(sql, " ").concat(v.sort);
|
|
661
674
|
}).join(', '));
|
|
662
675
|
}
|
package/lib/es/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[];
|