cache中对missedRows的处理有小bug,已经修改
This commit is contained in:
parent
403ce71c0b
commit
afc2d1c40c
|
|
@ -42,7 +42,7 @@ export declare class Cache<ED extends EntityDict & BaseEntityDict, Cxt extends A
|
|||
operation: ED[keyof ED]['Operation'];
|
||||
}>, allowMiss?: boolean): Partial<ED[T]["Schema"]>[];
|
||||
private getInner;
|
||||
get<T extends keyof ED>(entity: T, selection: ED[T]['Selection'], params?: SelectOption): Partial<ED[T]["Schema"]>[];
|
||||
get<T extends keyof ED>(entity: T, selection: ED[T]['Selection'], allowMiss?: boolean): Partial<ED[T]["Schema"]>[];
|
||||
judgeRelation(entity: keyof ED, attr: string): string | 0 | 1 | 2 | string[];
|
||||
bindOnSync(callback: (opRecords: OpRecord<ED>[]) => void): void;
|
||||
unbindOnSync(callback: (opRecords: OpRecord<ED>[]) => void): void;
|
||||
|
|
|
|||
|
|
@ -221,19 +221,29 @@ var Cache = /** @class */ (function (_super) {
|
|||
catch (err) {
|
||||
if (err instanceof Exception_1.OakRowUnexistedException) {
|
||||
if (!allowMiss) {
|
||||
var missedRows = err.getRows();
|
||||
this.exec('fetchRows', missedRows, function (result, opRecords) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
||||
var opRecords_1, opRecords_1_1, record, d, e;
|
||||
var e_3, _a;
|
||||
return tslib_1.__generator(this, function (_b) {
|
||||
var missedRows_1 = err.getRows();
|
||||
this.exec('fetchRows', missedRows_1, function (result, opRecords) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
||||
var opRecords_1, opRecords_1_1, record, d, missedRows_2, missedRows_2_1, mr;
|
||||
var e_3, _a, e_4, _b;
|
||||
return tslib_1.__generator(this, function (_c) {
|
||||
try {
|
||||
// missedRows理论上一定要取到,不能为空集。否则就是程序员有遗漏
|
||||
for (opRecords_1 = tslib_1.__values(opRecords), opRecords_1_1 = opRecords_1.next(); !opRecords_1_1.done; opRecords_1_1 = opRecords_1.next()) {
|
||||
record = opRecords_1_1.value;
|
||||
d = record.d;
|
||||
(0, assert_1.default)(Object.keys(d).length > 0, '在通过fetchRow取不一致数据时返回了空数据,请拿该程序员祭天。');
|
||||
for (e in d) {
|
||||
(0, assert_1.default)(Object.keys(d[e]).length > 0, "\u5728\u901A\u8FC7fetchRow\u53D6\u4E0D\u4E00\u81F4\u6570\u636E\u65F6\u8FD4\u56DE\u4E86\u7A7A\u6570\u636E\uFF0C\u8BF7\u62FF\u8BE5\u7A0B\u5E8F\u5458\u796D\u5929\u3002entity\u662F".concat(e));
|
||||
try {
|
||||
for (missedRows_2 = (e_4 = void 0, tslib_1.__values(missedRows_1)), missedRows_2_1 = missedRows_2.next(); !missedRows_2_1.done; missedRows_2_1 = missedRows_2.next()) {
|
||||
mr = missedRows_2_1.value;
|
||||
(0, assert_1.default)(Object.keys(d[mr.entity]).length > 0, "\u5728\u901A\u8FC7fetchRow\u53D6\u4E0D\u4E00\u81F4\u6570\u636E\u65F6\u8FD4\u56DE\u4E86\u7A7A\u6570\u636E\uFF0C\u8BF7\u62FF\u8BE5\u7A0B\u5E8F\u5458\u796D\u5929\u3002entity\u662F".concat(mr.entity));
|
||||
}
|
||||
}
|
||||
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
||||
finally {
|
||||
try {
|
||||
if (missedRows_2_1 && !missedRows_2_1.done && (_b = missedRows_2.return)) _b.call(missedRows_2);
|
||||
}
|
||||
finally { if (e_4) throw e_4.error; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -255,9 +265,9 @@ var Cache = /** @class */ (function (_super) {
|
|||
}
|
||||
}
|
||||
};
|
||||
Cache.prototype.get = function (entity, selection, params) {
|
||||
Cache.prototype.get = function (entity, selection, allowMiss) {
|
||||
var context = this.contextBuilder();
|
||||
return this.getInner(entity, selection, context);
|
||||
return this.getInner(entity, selection, context, allowMiss);
|
||||
};
|
||||
Cache.prototype.judgeRelation = function (entity, attr) {
|
||||
return this.cacheStore.judgeRelation(entity, attr);
|
||||
|
|
|
|||
|
|
@ -239,8 +239,8 @@ export class Cache<
|
|||
for (const record of opRecords) {
|
||||
const { d } = record as SelectOpResult<ED>;
|
||||
assert(Object.keys(d).length > 0, '在通过fetchRow取不一致数据时返回了空数据,请拿该程序员祭天。');
|
||||
for (const e in d) {
|
||||
assert(Object.keys(d![e]!).length > 0, `在通过fetchRow取不一致数据时返回了空数据,请拿该程序员祭天。entity是${e}`);
|
||||
for (const mr of missedRows) {
|
||||
assert(Object.keys(d![mr.entity]!).length > 0, `在通过fetchRow取不一致数据时返回了空数据,请拿该程序员祭天。entity是${mr.entity}`);
|
||||
}
|
||||
}
|
||||
})
|
||||
|
|
@ -255,11 +255,11 @@ export class Cache<
|
|||
get<T extends keyof ED>(
|
||||
entity: T,
|
||||
selection: ED[T]['Selection'],
|
||||
params?: SelectOption
|
||||
allowMiss?: boolean,
|
||||
) {
|
||||
const context = this.contextBuilder!();
|
||||
|
||||
return this.getInner(entity, selection, context);
|
||||
return this.getInner(entity, selection, context, allowMiss);
|
||||
}
|
||||
|
||||
judgeRelation(entity: keyof ED, attr: string) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue