在addToResultSelections时没有正确处理外键为空
This commit is contained in:
parent
a32eaf5856
commit
11ab7844ed
|
|
@ -1758,8 +1758,10 @@ var CascadeStore = /** @class */ (function (_super) {
|
|||
* @param context
|
||||
*/
|
||||
CascadeStore.prototype.addToResultSelections = function (entity, rows, context) {
|
||||
var e_12, _a;
|
||||
if (this.supportManyToOneJoin()) {
|
||||
var attrsToPick_1 = [];
|
||||
// 这里的外键连接有可能为空,需要使用所有的行的attr的并集来测试
|
||||
var attrsToPick_2 = (0, lodash_1.uniq)(rows.map(function (ele) { return Object.keys(ele); }).flat());
|
||||
var _loop_3 = function (attr) {
|
||||
var data = {};
|
||||
var rel = this_3.judgeRelation(entity, attr);
|
||||
|
|
@ -1773,14 +1775,24 @@ var CascadeStore = /** @class */ (function (_super) {
|
|||
this_3.addToResultSelections(rel[0], rows.map(function (ele) { return ele[attr]; }).reduce(function (prev, current) { return prev.concat(current); }, []), context);
|
||||
}
|
||||
else {
|
||||
attrsToPick_1.push(attr);
|
||||
attrsToPick_2.push(attr);
|
||||
}
|
||||
};
|
||||
var this_3 = this;
|
||||
for (var attr in rows[0]) {
|
||||
try {
|
||||
for (var attrsToPick_1 = tslib_1.__values(attrsToPick_2), attrsToPick_1_1 = attrsToPick_1.next(); !attrsToPick_1_1.done; attrsToPick_1_1 = attrsToPick_1.next()) {
|
||||
var attr = attrsToPick_1_1.value;
|
||||
_loop_3(attr);
|
||||
}
|
||||
var originRows = rows.map(function (ele) { return (0, lodash_1.pick)(ele, attrsToPick_1); });
|
||||
}
|
||||
catch (e_12_1) { e_12 = { error: e_12_1 }; }
|
||||
finally {
|
||||
try {
|
||||
if (attrsToPick_1_1 && !attrsToPick_1_1.done && (_a = attrsToPick_1.return)) _a.call(attrsToPick_1);
|
||||
}
|
||||
finally { if (e_12) throw e_12.error; }
|
||||
}
|
||||
var originRows = rows.map(function (ele) { return (0, lodash_1.pick)(ele, attrsToPick_2); });
|
||||
this.addSingleRowToResultSelections(entity, originRows, context);
|
||||
}
|
||||
else {
|
||||
|
|
@ -1858,7 +1870,7 @@ var CascadeStore = /** @class */ (function (_super) {
|
|||
if (!(cascadeSelectionFns.length > 0)) return [3 /*break*/, 3];
|
||||
ruException_2 = [];
|
||||
return [4 /*yield*/, Promise.all(cascadeSelectionFns.map(function (ele) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
||||
var e_12, rows_2;
|
||||
var e_13, rows_2;
|
||||
return tslib_1.__generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0:
|
||||
|
|
@ -1868,13 +1880,13 @@ var CascadeStore = /** @class */ (function (_super) {
|
|||
_a.sent();
|
||||
return [3 /*break*/, 3];
|
||||
case 2:
|
||||
e_12 = _a.sent();
|
||||
if (e_12 instanceof types_1.OakRowUnexistedException) {
|
||||
rows_2 = e_12.getRows();
|
||||
e_13 = _a.sent();
|
||||
if (e_13 instanceof types_1.OakRowUnexistedException) {
|
||||
rows_2 = e_13.getRows();
|
||||
ruException_2.push.apply(ruException_2, tslib_1.__spreadArray([], tslib_1.__read(rows_2), false));
|
||||
}
|
||||
else {
|
||||
throw e_12;
|
||||
throw e_13;
|
||||
}
|
||||
return [3 /*break*/, 3];
|
||||
case 3: return [2 /*return*/];
|
||||
|
|
|
|||
|
|
@ -1794,8 +1794,11 @@ export abstract class CascadeStore<ED extends EntityDict & BaseEntityDict> exten
|
|||
*/
|
||||
private addToResultSelections<T extends keyof ED, Cxt extends AsyncContext<ED>>(entity: T, rows: Partial<ED[T]['Schema']>[], context: Cxt) {
|
||||
if (this.supportManyToOneJoin()) {
|
||||
const attrsToPick: string[] = [];
|
||||
for (const attr in rows[0]) {
|
||||
// 这里的外键连接有可能为空,需要使用所有的行的attr的并集来测试
|
||||
const attrsToPick: string[] = uniq(rows.map(
|
||||
ele => Object.keys(ele)
|
||||
).flat());
|
||||
for (const attr of attrsToPick) {
|
||||
const data: Partial<ED[T]['Schema']> = {}
|
||||
const rel = this.judgeRelation(entity, attr);
|
||||
if (rel === 2) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue