@gingkoo/pandora-metabase 1.0.157-alpha.3 → 1.0.157-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/lib/cjs/store/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { DatasourceType } from '../types';
|
|
2
|
-
import { TypeEnum, SpecialType, JoinEnum, SQL_COLUMN_TYPE, SortEnum } from './enum';
|
|
2
|
+
import { TypeEnum, SpecialType, JoinEnum, SQL_COLUMN_TYPE, SortEnum, UnionEnum } from './enum';
|
|
3
3
|
export declare enum FormulaTypeEnum {
|
|
4
4
|
CUSTOM = "custom",
|
|
5
5
|
FILTER = "filter",
|
|
@@ -210,6 +210,7 @@ export interface MetaData_ColumnsType {
|
|
|
210
210
|
}
|
|
211
211
|
export interface MetaData {
|
|
212
212
|
metaKey: number;
|
|
213
|
+
patchVersion?: string;
|
|
213
214
|
readonly?: boolean;
|
|
214
215
|
hidden?: boolean;
|
|
215
216
|
type: TypeEnum.data;
|
|
@@ -351,6 +352,7 @@ export interface MetaPermissionTable {
|
|
|
351
352
|
export interface MetaUnion {
|
|
352
353
|
metaKey: number;
|
|
353
354
|
type: TypeEnum.union;
|
|
355
|
+
union: UnionEnum;
|
|
354
356
|
subquery: MetaListType[];
|
|
355
357
|
}
|
|
356
358
|
export interface LooseObject {
|
|
@@ -40,7 +40,10 @@ var BlockTypeEnum = {
|
|
|
40
40
|
exists: 'exists',
|
|
41
41
|
FORMULA: 'FORMULA',
|
|
42
42
|
collection: 'collection',
|
|
43
|
-
andOr: 'andOr'
|
|
43
|
+
andOr: 'andOr',
|
|
44
|
+
caseWhen: 'caseWhen',
|
|
45
|
+
select: 'select',
|
|
46
|
+
subquery: 'subquery'
|
|
44
47
|
};
|
|
45
48
|
var SummarizeAlias = 'source';
|
|
46
49
|
var SQL_GROUP_TYPE = {
|
|
@@ -496,6 +499,38 @@ var _handleBaseType2Sql9 = exports.handleBaseType2Sql = function handleBaseType2
|
|
|
496
499
|
sql += " ".concat(collectionSql);
|
|
497
500
|
constants.push.apply(constants, (0, _toConsumableArray2["default"])(collectionConstants));
|
|
498
501
|
}
|
|
502
|
+
if (type === BlockTypeEnum.select) {
|
|
503
|
+
var values = (Array.isArray(item.val) ? item.val : [item.val]).filter(function (value) {
|
|
504
|
+
return value !== null && value !== undefined && value !== '';
|
|
505
|
+
}).map(function (value) {
|
|
506
|
+
return String(value);
|
|
507
|
+
});
|
|
508
|
+
var selectSql = values.join(', ');
|
|
509
|
+
sql += selectSql ? " ".concat(selectSql) : '';
|
|
510
|
+
sql_items.push.apply(sql_items, (0, _toConsumableArray2["default"])(values));
|
|
511
|
+
}
|
|
512
|
+
if (type === BlockTypeEnum.subquery) {
|
|
513
|
+
if (Array.isArray(item.subQuery) && item.subQuery.length) {
|
|
514
|
+
sql += " (".concat(handleSqlUnion(item.subQuery, db).sql, ")");
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
if (type === BlockTypeEnum.caseWhen) {
|
|
518
|
+
var caseSqlResult = _handleBaseType2Sql9(item.caseAtoms || [], db);
|
|
519
|
+
constants.push.apply(constants, (0, _toConsumableArray2["default"])(caseSqlResult.constants));
|
|
520
|
+
var whenSql = (item.whenClauses || []).map(function (clause) {
|
|
521
|
+
var whenResult = _handleBaseType2Sql9(clause.whenAtoms || [], db);
|
|
522
|
+
var thenResult = _handleBaseType2Sql9(clause.thenAtoms || [], db);
|
|
523
|
+
constants.push.apply(constants, (0, _toConsumableArray2["default"])(whenResult.constants).concat((0, _toConsumableArray2["default"])(thenResult.constants)));
|
|
524
|
+
var whenCondition = whenResult.sql.trim();
|
|
525
|
+
var thenValue = thenResult.sql.trim();
|
|
526
|
+
return whenCondition && thenValue ? "WHEN ".concat(whenCondition, " THEN ").concat(thenValue) : '';
|
|
527
|
+
}).filter(Boolean).join(' ');
|
|
528
|
+
var elseResult = _handleBaseType2Sql9(item.elseAtoms || [], db);
|
|
529
|
+
constants.push.apply(constants, (0, _toConsumableArray2["default"])(elseResult.constants));
|
|
530
|
+
var caseExpression = caseSqlResult.sql.trim();
|
|
531
|
+
var elseSql = elseResult.sql.trim();
|
|
532
|
+
sql += " CASE".concat(caseExpression ? " ".concat(caseExpression) : '').concat(whenSql ? " ".concat(whenSql) : '').concat(elseSql ? " ELSE ".concat(elseSql) : '', " END");
|
|
533
|
+
}
|
|
499
534
|
if (type === BlockTypeEnum.andOr) {
|
|
500
535
|
var itemsSql = normalizeAndOrItems(item).map(function (logicItem, index) {
|
|
501
536
|
var _handleBaseType2Sql8 = _handleBaseType2Sql9(logicItem.atoms || [], db),
|
|
@@ -755,7 +790,7 @@ var handleSqlUnion = function handleSqlUnion(metas) {
|
|
|
755
790
|
unionMetas.forEach(function (it) {
|
|
756
791
|
if (Array.isArray(it.subquery) && it.subquery.length) {
|
|
757
792
|
var u_data = handleSqlStruct(it.subquery, db);
|
|
758
|
-
var _sqlStruct2text2 = _sqlStruct2text3(u_data, 0, db),
|
|
793
|
+
var _sqlStruct2text2 = _sqlStruct2text3(u_data, 0, db, noFields),
|
|
759
794
|
u_sqltext = _sqlStruct2text2.sql,
|
|
760
795
|
u_fields = _sqlStruct2text2.fields;
|
|
761
796
|
union_fields.push(u_fields);
|
package/lib/es/store/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { DatasourceType } from '../types';
|
|
2
|
-
import { TypeEnum, SpecialType, JoinEnum, SQL_COLUMN_TYPE, SortEnum } from './enum';
|
|
2
|
+
import { TypeEnum, SpecialType, JoinEnum, SQL_COLUMN_TYPE, SortEnum, UnionEnum } from './enum';
|
|
3
3
|
export declare enum FormulaTypeEnum {
|
|
4
4
|
CUSTOM = "custom",
|
|
5
5
|
FILTER = "filter",
|
|
@@ -210,6 +210,7 @@ export interface MetaData_ColumnsType {
|
|
|
210
210
|
}
|
|
211
211
|
export interface MetaData {
|
|
212
212
|
metaKey: number;
|
|
213
|
+
patchVersion?: string;
|
|
213
214
|
readonly?: boolean;
|
|
214
215
|
hidden?: boolean;
|
|
215
216
|
type: TypeEnum.data;
|
|
@@ -351,6 +352,7 @@ export interface MetaPermissionTable {
|
|
|
351
352
|
export interface MetaUnion {
|
|
352
353
|
metaKey: number;
|
|
353
354
|
type: TypeEnum.union;
|
|
355
|
+
union: UnionEnum;
|
|
354
356
|
subquery: MetaListType[];
|
|
355
357
|
}
|
|
356
358
|
export interface LooseObject {
|
|
@@ -33,7 +33,10 @@ var BlockTypeEnum = {
|
|
|
33
33
|
exists: 'exists',
|
|
34
34
|
FORMULA: 'FORMULA',
|
|
35
35
|
collection: 'collection',
|
|
36
|
-
andOr: 'andOr'
|
|
36
|
+
andOr: 'andOr',
|
|
37
|
+
caseWhen: 'caseWhen',
|
|
38
|
+
select: 'select',
|
|
39
|
+
subquery: 'subquery'
|
|
37
40
|
};
|
|
38
41
|
var SummarizeAlias = 'source';
|
|
39
42
|
var SQL_GROUP_TYPE = {
|
|
@@ -489,6 +492,38 @@ var _handleBaseType2Sql9 = function handleBaseType2Sql(list) {
|
|
|
489
492
|
sql += " ".concat(collectionSql);
|
|
490
493
|
constants.push.apply(constants, _toConsumableArray(collectionConstants));
|
|
491
494
|
}
|
|
495
|
+
if (type === BlockTypeEnum.select) {
|
|
496
|
+
var values = (Array.isArray(item.val) ? item.val : [item.val]).filter(function (value) {
|
|
497
|
+
return value !== null && value !== undefined && value !== '';
|
|
498
|
+
}).map(function (value) {
|
|
499
|
+
return String(value);
|
|
500
|
+
});
|
|
501
|
+
var selectSql = values.join(', ');
|
|
502
|
+
sql += selectSql ? " ".concat(selectSql) : '';
|
|
503
|
+
sql_items.push.apply(sql_items, _toConsumableArray(values));
|
|
504
|
+
}
|
|
505
|
+
if (type === BlockTypeEnum.subquery) {
|
|
506
|
+
if (Array.isArray(item.subQuery) && item.subQuery.length) {
|
|
507
|
+
sql += " (".concat(handleSqlUnion(item.subQuery, db).sql, ")");
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
if (type === BlockTypeEnum.caseWhen) {
|
|
511
|
+
var caseSqlResult = _handleBaseType2Sql9(item.caseAtoms || [], db);
|
|
512
|
+
constants.push.apply(constants, _toConsumableArray(caseSqlResult.constants));
|
|
513
|
+
var whenSql = (item.whenClauses || []).map(function (clause) {
|
|
514
|
+
var whenResult = _handleBaseType2Sql9(clause.whenAtoms || [], db);
|
|
515
|
+
var thenResult = _handleBaseType2Sql9(clause.thenAtoms || [], db);
|
|
516
|
+
constants.push.apply(constants, _toConsumableArray(whenResult.constants).concat(_toConsumableArray(thenResult.constants)));
|
|
517
|
+
var whenCondition = whenResult.sql.trim();
|
|
518
|
+
var thenValue = thenResult.sql.trim();
|
|
519
|
+
return whenCondition && thenValue ? "WHEN ".concat(whenCondition, " THEN ").concat(thenValue) : '';
|
|
520
|
+
}).filter(Boolean).join(' ');
|
|
521
|
+
var elseResult = _handleBaseType2Sql9(item.elseAtoms || [], db);
|
|
522
|
+
constants.push.apply(constants, _toConsumableArray(elseResult.constants));
|
|
523
|
+
var caseExpression = caseSqlResult.sql.trim();
|
|
524
|
+
var elseSql = elseResult.sql.trim();
|
|
525
|
+
sql += " CASE".concat(caseExpression ? " ".concat(caseExpression) : '').concat(whenSql ? " ".concat(whenSql) : '').concat(elseSql ? " ELSE ".concat(elseSql) : '', " END");
|
|
526
|
+
}
|
|
492
527
|
if (type === BlockTypeEnum.andOr) {
|
|
493
528
|
var itemsSql = normalizeAndOrItems(item).map(function (logicItem, index) {
|
|
494
529
|
var _handleBaseType2Sql8 = _handleBaseType2Sql9(logicItem.atoms || [], db),
|
|
@@ -749,7 +784,7 @@ var handleSqlUnion = function handleSqlUnion(metas) {
|
|
|
749
784
|
unionMetas.forEach(function (it) {
|
|
750
785
|
if (Array.isArray(it.subquery) && it.subquery.length) {
|
|
751
786
|
var u_data = handleSqlStruct(it.subquery, db);
|
|
752
|
-
var _sqlStruct2text2 = _sqlStruct2text3(u_data, 0, db),
|
|
787
|
+
var _sqlStruct2text2 = _sqlStruct2text3(u_data, 0, db, noFields),
|
|
753
788
|
u_sqltext = _sqlStruct2text2.sql,
|
|
754
789
|
u_fields = _sqlStruct2text2.fields;
|
|
755
790
|
union_fields.push(u_fields);
|