@gingkoo/pandora-metabase 1.0.157 → 1.0.158-alpha.2

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.
@@ -32,13 +32,14 @@ var _dateFormatPicker = require("./date-format-picker");
32
32
  function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
33
33
  var NUMBER_LIST = ['等于', '不等于', '大于', '小于', '介于之间', '大于或等于', '小于或等于', '为空', '不为空', '以...开始', '以...结束', '不以...开始', '不以...结束', 'In', 'Not In', '正则匹配'];
34
34
  var STRING_LIST = ['等于', '不等于', '大于', '小于', '大于或等于', '小于或等于', '包含', '不包含', '为空', '不为空', '以...开始', '以...结束', '不以...开始', '不以...结束', 'In', 'Not In', '正则匹配'];
35
- var DATE_LIST = ['等于', '大于', '小于', '大于或等于', '小于或等于', '介于之间', '是空的', '不为空'];
35
+ var DATE_LIST = ['等于', '大于', '小于', '大于或等于', '小于或等于', '介于之间', '为空', '不为空'];
36
36
  var DATE_VALUE_CONDITIONS = ['等于', '大于', '小于', '大于或等于', '小于或等于', '早于', '晚于', '在'];
37
37
  var SWITCH_VALUE_TYPE_CONDITIONS = ['等于', '不等于', '大于', '小于', '大于或等于', '小于或等于'];
38
38
  var LEGACY_DATE_CONDITION_MAP = {
39
39
  早于: '小于',
40
40
  晚于: '大于或等于'
41
41
  };
42
+ var LEGACY_EMPTY_CONDITIONS = new Set(['是空的', '不是空的']);
42
43
  var typeList = [{
43
44
  key: _enum.SQL_COLUMN_TYPE.STRING,
44
45
  label: _enum.SQL_COLUMN_TYPE.STRING
@@ -75,7 +76,7 @@ var SelectFilterColumn = function SelectFilterColumn(_ref) {
75
76
  _ref$filterCustomType = _ref.filterCustomType,
76
77
  filterCustomType = _ref$filterCustomType === void 0 ? false : _ref$filterCustomType,
77
78
  parentPopupChannel = _ref.parentPopupChannel;
78
- var normalizedInitialValue = (0, _utils.normalizeExpressionAtom)(value, data);
79
+ var normalizedInitialValue = (0, _utils.normalizeExpressionAtom)(value, data, filterCustomType);
79
80
  var _useState = (0, _react.useState)(normalizedInitialValue),
80
81
  _useState2 = (0, _slicedToArray2["default"])(_useState, 2),
81
82
  curColumn = _useState2[0],
@@ -332,7 +333,7 @@ var SelectFilterColumn = function SelectFilterColumn(_ref) {
332
333
  rhs: rhsVal,
333
334
  condition: condition,
334
335
  database_type: databaseType
335
- }), filterCustomType ? [] : data);
336
+ }), data, filterCustomType);
336
337
  var quotes = generateQuotes(nextExpression.rhs, nextExpression);
337
338
  typeof onChange === 'function' && onChange((0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, nextExpression), {}, {
338
339
  quotes: quotes
@@ -361,8 +362,8 @@ var SelectFilterColumn = function SelectFilterColumn(_ref) {
361
362
  if (isCustom) {
362
363
  conditions = ['无需结果'].concat((0, _toConsumableArray2["default"])(conditions));
363
364
  }
364
- var isCompatibleDateEmptyCondition = type === _enum.SQL_GROUP_TYPE.DATE && (condition === '为空' || condition === '不是空的');
365
- if (!conditions.includes(condition) && !nextCondition && !isCompatibleDateEmptyCondition) {
365
+ var isLegacyEmptyCondition = LEGACY_EMPTY_CONDITIONS.has(condition);
366
+ if (!conditions.includes(condition) && !nextCondition && !isLegacyEmptyCondition) {
366
367
  setDefaultVal(conditions[0], type);
367
368
  }
368
369
  return {
@@ -1019,7 +1020,7 @@ var SelectFilterColumn = function SelectFilterColumn(_ref) {
1019
1020
  onSelect: function onSelect(fields, quotes) {
1020
1021
  setCurColumn((0, _utils.normalizeExpressionAtom)((0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, curColumn), {}, {
1021
1022
  lhs: fields
1022
- }), data));
1023
+ }), data, filterCustomType));
1023
1024
  setIsNext(true);
1024
1025
  }
1025
1026
  })
@@ -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: ({
@@ -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 databaseType = getExpressionDatabaseType(expression, tables);
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)
@@ -78,11 +78,9 @@ var sanitizeAliasPart = function sanitizeAliasPart() {
78
78
  var value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
79
79
  return value.replace(/[^a-zA-Z0-9_]/g, '_').replace(/_+/g, '_').replace(/^_+|_+$/g, '');
80
80
  };
81
- var buildAutoGroupByAlias = function buildAutoGroupByAlias(tableAlias, fieldName, itemIndex) {
81
+ var buildAutoGroupByAlias = function buildAutoGroupByAlias(fieldName, itemIndex) {
82
82
  var fallbackAlias = "group_by_".concat(itemIndex + 1);
83
- var aliasPrefix = sanitizeAliasPart(tableAlias);
84
- var aliasField = sanitizeAliasPart(fieldName);
85
- var autoAlias = (aliasPrefix && aliasField ? "".concat(aliasPrefix, "__").concat(aliasField) : aliasField || aliasPrefix) || fallbackAlias;
83
+ var autoAlias = sanitizeAliasPart(fieldName) || fallbackAlias;
86
84
  if (!/^[a-zA-Z]/.test(autoAlias)) {
87
85
  autoAlias = "a_".concat(autoAlias.replace(/^[^a-zA-Z]+/, ''));
88
86
  }
@@ -485,7 +483,6 @@ var GroupBy = function GroupBy(props) {
485
483
  return _getFirstField(atoms) || getField(record);
486
484
  };
487
485
  var normalizeByRecord = function normalizeByRecord(record, itemIndex, metaList) {
488
- var _store$preProps;
489
486
  var atoms = getAtomsValue(record);
490
487
  var firstField = _getFirstField(atoms);
491
488
  var nextRecord = (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, record), {}, {
@@ -508,7 +505,14 @@ var GroupBy = function GroupBy(props) {
508
505
  nextRecord.datasourceName = firstField.datasourceName || nextRecord.datasourceName;
509
506
  nextRecord.database_type = firstField.database_type || nextRecord.database_type;
510
507
  }
511
- var defaultFieldAlias = firstField !== null && firstField !== void 0 && firstField.fieldName ? buildAutoGroupByAlias((0, _helper.getAlias)(firstField.tableAlias || nextRecord.alias, metaList, ((_store$preProps = store.preProps) === null || _store$preProps === void 0 ? void 0 : _store$preProps.notExistsColumns) || []), firstField.fieldName, itemIndex) : "group_by_".concat(itemIndex + 1);
508
+ var usedAliases = meta.by.filter(function (_, idx) {
509
+ return idx !== itemIndex;
510
+ }).map(function (item) {
511
+ return item.fieldAlias;
512
+ }).filter(function (alias) {
513
+ return Boolean(alias);
514
+ });
515
+ var defaultFieldAlias = firstField !== null && firstField !== void 0 && firstField.fieldName ? (0, _helper.getAlias)(buildAutoGroupByAlias(firstField.fieldName, itemIndex), [], [], usedAliases) : "group_by_".concat(itemIndex + 1);
512
516
  nextRecord.fieldAlias = nextRecord.fieldAlias || defaultFieldAlias;
513
517
  nextRecord.fieldUuid = nextRecord.fieldUuid || (0, _helper.uuidv4)('field');
514
518
  nextRecord.sql = (0, _helper2.summarizeByToSql)(nextRecord);
@@ -277,9 +277,11 @@ var _handleBaseType2Sql9 = exports.handleBaseType2Sql = function handleBaseType2
277
277
  _right_condition = "NOT LIKE '%".concat(condition_1, "%'");
278
278
  break;
279
279
  case '为空':
280
+ case '是空的':
280
281
  _right_condition = "IS NULL";
281
282
  break;
282
283
  case '不为空':
284
+ case '不是空的':
283
285
  _right_condition = "IS NOT NULL";
284
286
  break;
285
287
  case '以...开始':
@@ -359,9 +361,11 @@ var _handleBaseType2Sql9 = exports.handleBaseType2Sql = function handleBaseType2
359
361
  _right_condition = "<= ".concat(_condition_3);
360
362
  break;
361
363
  case '为空':
364
+ case '是空的':
362
365
  _right_condition = "IS NULL";
363
366
  break;
364
367
  case '不为空':
368
+ case '不是空的':
365
369
  _right_condition = "IS NOT NULL";
366
370
  break;
367
371
  case '以...开始':
package/lib/cjs/utils.js CHANGED
@@ -574,6 +574,7 @@ var getExpressionConditionText = function getExpressionConditionText(condition)
574
574
  早于: 'filter.earlierThan',
575
575
  晚于: 'filter.laterThan',
576
576
  是空的: 'filter.isEmpty',
577
+ 不是空的: 'filter.notEmpty',
577
578
  In: 'filter.within',
578
579
  'Not In': 'filter.withnotin',
579
580
  无需结果: 'filter.notresults',
@@ -24,13 +24,14 @@ import ItemName from '../../modules/components/item-name';
24
24
  import { DateFormatPicker, DateRangeFormatPicker } from './date-format-picker';
25
25
  var NUMBER_LIST = ['等于', '不等于', '大于', '小于', '介于之间', '大于或等于', '小于或等于', '为空', '不为空', '以...开始', '以...结束', '不以...开始', '不以...结束', 'In', 'Not In', '正则匹配'];
26
26
  var STRING_LIST = ['等于', '不等于', '大于', '小于', '大于或等于', '小于或等于', '包含', '不包含', '为空', '不为空', '以...开始', '以...结束', '不以...开始', '不以...结束', 'In', 'Not In', '正则匹配'];
27
- var DATE_LIST = ['等于', '大于', '小于', '大于或等于', '小于或等于', '介于之间', '是空的', '不为空'];
27
+ var DATE_LIST = ['等于', '大于', '小于', '大于或等于', '小于或等于', '介于之间', '为空', '不为空'];
28
28
  var DATE_VALUE_CONDITIONS = ['等于', '大于', '小于', '大于或等于', '小于或等于', '早于', '晚于', '在'];
29
29
  var SWITCH_VALUE_TYPE_CONDITIONS = ['等于', '不等于', '大于', '小于', '大于或等于', '小于或等于'];
30
30
  var LEGACY_DATE_CONDITION_MAP = {
31
31
  早于: '小于',
32
32
  晚于: '大于或等于'
33
33
  };
34
+ var LEGACY_EMPTY_CONDITIONS = new Set(['是空的', '不是空的']);
34
35
  var typeList = [{
35
36
  key: SQL_COLUMN_TYPE.STRING,
36
37
  label: SQL_COLUMN_TYPE.STRING
@@ -67,7 +68,7 @@ var SelectFilterColumn = function SelectFilterColumn(_ref) {
67
68
  _ref$filterCustomType = _ref.filterCustomType,
68
69
  filterCustomType = _ref$filterCustomType === void 0 ? false : _ref$filterCustomType,
69
70
  parentPopupChannel = _ref.parentPopupChannel;
70
- var normalizedInitialValue = normalizeExpressionAtom(value, data);
71
+ var normalizedInitialValue = normalizeExpressionAtom(value, data, filterCustomType);
71
72
  var _useState = useState(normalizedInitialValue),
72
73
  _useState2 = _slicedToArray(_useState, 2),
73
74
  curColumn = _useState2[0],
@@ -324,7 +325,7 @@ var SelectFilterColumn = function SelectFilterColumn(_ref) {
324
325
  rhs: rhsVal,
325
326
  condition: condition,
326
327
  database_type: databaseType
327
- }), filterCustomType ? [] : data);
328
+ }), data, filterCustomType);
328
329
  var quotes = generateQuotes(nextExpression.rhs, nextExpression);
329
330
  typeof onChange === 'function' && onChange(_objectSpread(_objectSpread({}, nextExpression), {}, {
330
331
  quotes: quotes
@@ -353,8 +354,8 @@ var SelectFilterColumn = function SelectFilterColumn(_ref) {
353
354
  if (isCustom) {
354
355
  conditions = ['无需结果'].concat(_toConsumableArray(conditions));
355
356
  }
356
- var isCompatibleDateEmptyCondition = type === SQL_GROUP_TYPE.DATE && (condition === '为空' || condition === '不是空的');
357
- if (!conditions.includes(condition) && !nextCondition && !isCompatibleDateEmptyCondition) {
357
+ var isLegacyEmptyCondition = LEGACY_EMPTY_CONDITIONS.has(condition);
358
+ if (!conditions.includes(condition) && !nextCondition && !isLegacyEmptyCondition) {
358
359
  setDefaultVal(conditions[0], type);
359
360
  }
360
361
  return {
@@ -1011,7 +1012,7 @@ var SelectFilterColumn = function SelectFilterColumn(_ref) {
1011
1012
  onSelect: function onSelect(fields, quotes) {
1012
1013
  setCurColumn(normalizeExpressionAtom(_objectSpread(_objectSpread({}, curColumn), {}, {
1013
1014
  lhs: fields
1014
- }), data));
1015
+ }), data, filterCustomType));
1015
1016
  setIsNext(true);
1016
1017
  }
1017
1018
  })
@@ -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: ({
@@ -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 databaseType = getExpressionDatabaseType(expression, tables);
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)
@@ -72,11 +72,9 @@ var sanitizeAliasPart = function sanitizeAliasPart() {
72
72
  var value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
73
73
  return value.replace(/[^a-zA-Z0-9_]/g, '_').replace(/_+/g, '_').replace(/^_+|_+$/g, '');
74
74
  };
75
- var buildAutoGroupByAlias = function buildAutoGroupByAlias(tableAlias, fieldName, itemIndex) {
75
+ var buildAutoGroupByAlias = function buildAutoGroupByAlias(fieldName, itemIndex) {
76
76
  var fallbackAlias = "group_by_".concat(itemIndex + 1);
77
- var aliasPrefix = sanitizeAliasPart(tableAlias);
78
- var aliasField = sanitizeAliasPart(fieldName);
79
- var autoAlias = (aliasPrefix && aliasField ? "".concat(aliasPrefix, "__").concat(aliasField) : aliasField || aliasPrefix) || fallbackAlias;
77
+ var autoAlias = sanitizeAliasPart(fieldName) || fallbackAlias;
80
78
  if (!/^[a-zA-Z]/.test(autoAlias)) {
81
79
  autoAlias = "a_".concat(autoAlias.replace(/^[^a-zA-Z]+/, ''));
82
80
  }
@@ -479,7 +477,6 @@ var GroupBy = function GroupBy(props) {
479
477
  return _getFirstField(atoms) || getField(record);
480
478
  };
481
479
  var normalizeByRecord = function normalizeByRecord(record, itemIndex, metaList) {
482
- var _store$preProps;
483
480
  var atoms = getAtomsValue(record);
484
481
  var firstField = _getFirstField(atoms);
485
482
  var nextRecord = _objectSpread(_objectSpread({}, record), {}, {
@@ -502,7 +499,14 @@ var GroupBy = function GroupBy(props) {
502
499
  nextRecord.datasourceName = firstField.datasourceName || nextRecord.datasourceName;
503
500
  nextRecord.database_type = firstField.database_type || nextRecord.database_type;
504
501
  }
505
- var defaultFieldAlias = firstField !== null && firstField !== void 0 && firstField.fieldName ? buildAutoGroupByAlias(getAlias(firstField.tableAlias || nextRecord.alias, metaList, ((_store$preProps = store.preProps) === null || _store$preProps === void 0 ? void 0 : _store$preProps.notExistsColumns) || []), firstField.fieldName, itemIndex) : "group_by_".concat(itemIndex + 1);
502
+ var usedAliases = meta.by.filter(function (_, idx) {
503
+ return idx !== itemIndex;
504
+ }).map(function (item) {
505
+ return item.fieldAlias;
506
+ }).filter(function (alias) {
507
+ return Boolean(alias);
508
+ });
509
+ var defaultFieldAlias = firstField !== null && firstField !== void 0 && firstField.fieldName ? getAlias(buildAutoGroupByAlias(firstField.fieldName, itemIndex), [], [], usedAliases) : "group_by_".concat(itemIndex + 1);
506
510
  nextRecord.fieldAlias = nextRecord.fieldAlias || defaultFieldAlias;
507
511
  nextRecord.fieldUuid = nextRecord.fieldUuid || uuidv4('field');
508
512
  nextRecord.sql = summarizeByToSql(nextRecord);
@@ -270,9 +270,11 @@ var _handleBaseType2Sql9 = function handleBaseType2Sql(list) {
270
270
  _right_condition = "NOT LIKE '%".concat(condition_1, "%'");
271
271
  break;
272
272
  case '为空':
273
+ case '是空的':
273
274
  _right_condition = "IS NULL";
274
275
  break;
275
276
  case '不为空':
277
+ case '不是空的':
276
278
  _right_condition = "IS NOT NULL";
277
279
  break;
278
280
  case '以...开始':
@@ -352,9 +354,11 @@ var _handleBaseType2Sql9 = function handleBaseType2Sql(list) {
352
354
  _right_condition = "<= ".concat(_condition_3);
353
355
  break;
354
356
  case '为空':
357
+ case '是空的':
355
358
  _right_condition = "IS NULL";
356
359
  break;
357
360
  case '不为空':
361
+ case '不是空的':
358
362
  _right_condition = "IS NOT NULL";
359
363
  break;
360
364
  case '以...开始':
package/lib/es/utils.js CHANGED
@@ -560,6 +560,7 @@ var getExpressionConditionText = function getExpressionConditionText(condition)
560
560
  早于: 'filter.earlierThan',
561
561
  晚于: 'filter.laterThan',
562
562
  是空的: 'filter.isEmpty',
563
+ 不是空的: 'filter.notEmpty',
563
564
  In: 'filter.within',
564
565
  'Not In': 'filter.withnotin',
565
566
  无需结果: 'filter.notresults',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gingkoo/pandora-metabase",
3
- "version": "1.0.157",
3
+ "version": "1.0.158-alpha.2",
4
4
  "description": "",
5
5
  "main": "lib/es/index.js",
6
6
  "module": "lib/es/index.js",