@gingkoo/pandora-metabase 1.0.125 → 1.0.126

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/utils.js CHANGED
@@ -282,12 +282,39 @@ var _changeAlias = function changeAlias(items, val, type) {
282
282
  });
283
283
  }
284
284
  return v;
285
+ } else if (v.type === _types.AtomsTypeEnum.SUB_QUERY) {
286
+ if (type === AliasType.table) {
287
+ v.subQuery = changeTableAlias(v.subQuery || [], {
288
+ tableUuid: val.uuid,
289
+ alias: val.alias
290
+ });
291
+ }
292
+ if (type === AliasType.field) {
293
+ v.subQuery = changeFieldAlias(v.subQuery || [], {
294
+ fieldUuid: val.uuid,
295
+ fieldAlias: val.alias
296
+ });
297
+ }
298
+ return v;
285
299
  } else if (v.type === _types.AtomsTypeEnum.FORMULA) {
286
300
  v.args = _changeAlias(v.args, val, type);
287
301
  return v;
288
302
  } else if (v.type === _types.AtomsTypeEnum.COLLECTION) {
289
303
  v.list = _changeAlias(v.list, val, type);
290
304
  return v;
305
+ } else if (v.type === _types.AtomsTypeEnum.CASE_WHEN) {
306
+ v.caseValue = _changeAlias(v.caseValue || [], val, type);
307
+ v.branches = (v.branches || []).map(function (branch) {
308
+ return (0, _objectSpread6["default"])((0, _objectSpread6["default"])({}, branch), {}, {
309
+ when: _changeAlias(branch.when || [], val, type),
310
+ then: _changeAlias(branch.then || [], val, type)
311
+ });
312
+ });
313
+ v.elseValue = _changeAlias(v.elseValue || [], val, type);
314
+ return v;
315
+ } else if (v.type === _types.AtomsTypeEnum.AND_OR) {
316
+ v.list = _changeAlias(v.list || [], val, type);
317
+ return v;
291
318
  } else {
292
319
  return v;
293
320
  }
@@ -353,27 +380,27 @@ var changeTableAlias = exports.changeTableAlias = function changeTableAlias(list
353
380
  }
354
381
  if (v.type === _enum.TypeEnum.summarize) {
355
382
  v.group.map(function (group) {
356
- if (group.tableUuid === tableUuid) {
383
+ var groupAtoms = group.atoms;
384
+ if (groupAtoms && groupAtoms.length > 0) {
385
+ group.atoms = _changeAlias(groupAtoms, {
386
+ uuid: tableUuid,
387
+ alias: alias
388
+ }, AliasType.table);
389
+ group.sql = (0, _helper.summarizeToSql)(v.group, group).sql;
390
+ } else if (group.tableUuid === tableUuid) {
357
391
  group.alias = alias;
358
- var groupAtoms = group.atoms;
359
- if (groupAtoms && groupAtoms.length > 0) {
360
- group.atoms = _changeAlias(groupAtoms, {
361
- uuid: tableUuid,
362
- alias: alias
363
- }, AliasType.table);
364
- }
365
392
  group.sql = (0, _helper.summarizeToSql)(v.group, group).sql;
366
393
  }
367
394
  });
368
395
  v.by.map(function (by) {
369
- if (by.tableUuid === tableUuid) {
396
+ if (by.atoms && by.atoms.length > 0) {
397
+ by.atoms = _changeAlias(by.atoms, {
398
+ uuid: tableUuid,
399
+ alias: alias
400
+ }, AliasType.table);
401
+ by.sql = (0, _helper.summarizeByToSql)(by);
402
+ } else if (by.tableUuid === tableUuid) {
370
403
  by.alias = alias;
371
- if (by.atoms && by.atoms.length > 0) {
372
- by.atoms = _changeAlias(by.atoms, {
373
- uuid: tableUuid,
374
- alias: alias
375
- }, AliasType.table);
376
- }
377
404
  by.sql = (0, _helper.summarizeByToSql)(by);
378
405
  }
379
406
  });
@@ -417,27 +444,27 @@ var changeFieldAlias = exports.changeFieldAlias = function changeFieldAlias(list
417
444
  if (v.type === _enum.TypeEnum.rowLimit) {}
418
445
  if (v.type === _enum.TypeEnum.summarize) {
419
446
  v.group.map(function (group) {
420
- if (group.fieldUuid === uuid) {
447
+ var groupAtoms = group.atoms;
448
+ if (groupAtoms && groupAtoms.length > 0) {
449
+ group.atoms = _changeAlias(groupAtoms, {
450
+ uuid: uuid,
451
+ alias: alias
452
+ }, AliasType.field);
453
+ group.sql = (0, _helper.summarizeToSql)(v.group, group).sql;
454
+ } else if (group.fieldUuid === uuid) {
421
455
  group.fieldAlias = alias;
422
- var groupAtoms = group.atoms;
423
- if (groupAtoms && groupAtoms.length > 0) {
424
- group.atoms = _changeAlias(groupAtoms, {
425
- uuid: uuid,
426
- alias: alias
427
- }, AliasType.field);
428
- }
429
456
  group.sql = (0, _helper.summarizeToSql)(v.group, group).sql;
430
457
  }
431
458
  });
432
459
  v.by.map(function (by) {
433
- if (by.fieldUuid === uuid) {
460
+ if (by.atoms && by.atoms.length > 0) {
461
+ by.atoms = _changeAlias(by.atoms, {
462
+ uuid: uuid,
463
+ alias: alias
464
+ }, AliasType.field);
465
+ by.sql = (0, _helper.summarizeByToSql)(by);
466
+ } else if (by.fieldUuid === uuid) {
434
467
  by.fieldAlias = alias;
435
- if (by.atoms && by.atoms.length > 0) {
436
- by.atoms = _changeAlias(by.atoms, {
437
- uuid: uuid,
438
- alias: alias
439
- }, AliasType.field);
440
- }
441
468
  by.sql = (0, _helper.summarizeByToSql)(by);
442
469
  }
443
470
  });
package/lib/es/utils.js CHANGED
@@ -269,12 +269,39 @@ var _changeAlias = function changeAlias(items, val, type) {
269
269
  });
270
270
  }
271
271
  return v;
272
+ } else if (v.type === AtomsTypeEnum.SUB_QUERY) {
273
+ if (type === AliasType.table) {
274
+ v.subQuery = changeTableAlias(v.subQuery || [], {
275
+ tableUuid: val.uuid,
276
+ alias: val.alias
277
+ });
278
+ }
279
+ if (type === AliasType.field) {
280
+ v.subQuery = changeFieldAlias(v.subQuery || [], {
281
+ fieldUuid: val.uuid,
282
+ fieldAlias: val.alias
283
+ });
284
+ }
285
+ return v;
272
286
  } else if (v.type === AtomsTypeEnum.FORMULA) {
273
287
  v.args = _changeAlias(v.args, val, type);
274
288
  return v;
275
289
  } else if (v.type === AtomsTypeEnum.COLLECTION) {
276
290
  v.list = _changeAlias(v.list, val, type);
277
291
  return v;
292
+ } else if (v.type === AtomsTypeEnum.CASE_WHEN) {
293
+ v.caseValue = _changeAlias(v.caseValue || [], val, type);
294
+ v.branches = (v.branches || []).map(function (branch) {
295
+ return _objectSpread(_objectSpread({}, branch), {}, {
296
+ when: _changeAlias(branch.when || [], val, type),
297
+ then: _changeAlias(branch.then || [], val, type)
298
+ });
299
+ });
300
+ v.elseValue = _changeAlias(v.elseValue || [], val, type);
301
+ return v;
302
+ } else if (v.type === AtomsTypeEnum.AND_OR) {
303
+ v.list = _changeAlias(v.list || [], val, type);
304
+ return v;
278
305
  } else {
279
306
  return v;
280
307
  }
@@ -340,27 +367,27 @@ export var changeTableAlias = function changeTableAlias(list, curObj) {
340
367
  }
341
368
  if (v.type === TypeEnum.summarize) {
342
369
  v.group.map(function (group) {
343
- if (group.tableUuid === tableUuid) {
370
+ var groupAtoms = group.atoms;
371
+ if (groupAtoms && groupAtoms.length > 0) {
372
+ group.atoms = _changeAlias(groupAtoms, {
373
+ uuid: tableUuid,
374
+ alias: alias
375
+ }, AliasType.table);
376
+ group.sql = summarizeToSql(v.group, group).sql;
377
+ } else if (group.tableUuid === tableUuid) {
344
378
  group.alias = alias;
345
- var groupAtoms = group.atoms;
346
- if (groupAtoms && groupAtoms.length > 0) {
347
- group.atoms = _changeAlias(groupAtoms, {
348
- uuid: tableUuid,
349
- alias: alias
350
- }, AliasType.table);
351
- }
352
379
  group.sql = summarizeToSql(v.group, group).sql;
353
380
  }
354
381
  });
355
382
  v.by.map(function (by) {
356
- if (by.tableUuid === tableUuid) {
383
+ if (by.atoms && by.atoms.length > 0) {
384
+ by.atoms = _changeAlias(by.atoms, {
385
+ uuid: tableUuid,
386
+ alias: alias
387
+ }, AliasType.table);
388
+ by.sql = summarizeByToSql(by);
389
+ } else if (by.tableUuid === tableUuid) {
357
390
  by.alias = alias;
358
- if (by.atoms && by.atoms.length > 0) {
359
- by.atoms = _changeAlias(by.atoms, {
360
- uuid: tableUuid,
361
- alias: alias
362
- }, AliasType.table);
363
- }
364
391
  by.sql = summarizeByToSql(by);
365
392
  }
366
393
  });
@@ -404,27 +431,27 @@ export var changeFieldAlias = function changeFieldAlias(list, curObj) {
404
431
  if (v.type === TypeEnum.rowLimit) {}
405
432
  if (v.type === TypeEnum.summarize) {
406
433
  v.group.map(function (group) {
407
- if (group.fieldUuid === uuid) {
434
+ var groupAtoms = group.atoms;
435
+ if (groupAtoms && groupAtoms.length > 0) {
436
+ group.atoms = _changeAlias(groupAtoms, {
437
+ uuid: uuid,
438
+ alias: alias
439
+ }, AliasType.field);
440
+ group.sql = summarizeToSql(v.group, group).sql;
441
+ } else if (group.fieldUuid === uuid) {
408
442
  group.fieldAlias = alias;
409
- var groupAtoms = group.atoms;
410
- if (groupAtoms && groupAtoms.length > 0) {
411
- group.atoms = _changeAlias(groupAtoms, {
412
- uuid: uuid,
413
- alias: alias
414
- }, AliasType.field);
415
- }
416
443
  group.sql = summarizeToSql(v.group, group).sql;
417
444
  }
418
445
  });
419
446
  v.by.map(function (by) {
420
- if (by.fieldUuid === uuid) {
447
+ if (by.atoms && by.atoms.length > 0) {
448
+ by.atoms = _changeAlias(by.atoms, {
449
+ uuid: uuid,
450
+ alias: alias
451
+ }, AliasType.field);
452
+ by.sql = summarizeByToSql(by);
453
+ } else if (by.fieldUuid === uuid) {
421
454
  by.fieldAlias = alias;
422
- if (by.atoms && by.atoms.length > 0) {
423
- by.atoms = _changeAlias(by.atoms, {
424
- uuid: uuid,
425
- alias: alias
426
- }, AliasType.field);
427
- }
428
455
  by.sql = summarizeByToSql(by);
429
456
  }
430
457
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gingkoo/pandora-metabase",
3
- "version": "1.0.125",
3
+ "version": "1.0.126",
4
4
  "description": "",
5
5
  "main": "lib/es/index.js",
6
6
  "module": "lib/es/index.js",