预防了projection写错

This commit is contained in:
Xu Chang 2023-07-26 16:28:01 +08:00
parent a8e7d54e1e
commit 9bd2a94509
2 changed files with 7 additions and 0 deletions

View File

@ -358,6 +358,7 @@ var CascadeStore = /** @class */ (function (_super) {
var cascadeSelectionFns = [];
var supportMtoJoin = this.supportManyToOneJoin();
var toModi = this.getSchema()[entity].toModi;
(0, assert_1.default)(typeof projection2 === 'object');
var _loop_1 = function (attr) {
var _a, _b, _c, _d;
var relation = (0, relation_1.judgeRelation)(this_1.storageSchema, entity, attr);
@ -372,6 +373,7 @@ var CascadeStore = /** @class */ (function (_super) {
entity: 1,
entityId: 1,
});
(0, assert_1.default)(typeof projection2[attr] === 'object');
if (supportMtoJoin) {
cascadeSelectionFns.push(function (result) {
if (!toModi) {
@ -462,6 +464,7 @@ var CascadeStore = /** @class */ (function (_super) {
Object.assign(projection, (_c = {},
_c["".concat(attr, "Id")] = 1,
_c));
(0, assert_1.default)(typeof projection2[attr] === 'object');
if (supportMtoJoin) {
if (!toModi) {
// 如果不是modi要保证外键没有空指针

View File

@ -409,6 +409,7 @@ export abstract class CascadeStore<ED extends EntityDict & BaseEntityDict> exten
const supportMtoJoin = this.supportManyToOneJoin();
const { toModi } = this.getSchema()[entity];
assert(typeof projection2 === 'object');
for (const attr in projection2) {
const relation = judgeRelation(this.storageSchema, entity, attr);
if (relation === 1 || relation == 0) {
@ -422,6 +423,8 @@ export abstract class CascadeStore<ED extends EntityDict & BaseEntityDict> exten
entity: 1,
entityId: 1,
});
assert(typeof projection2[attr] === 'object');
if (supportMtoJoin) {
cascadeSelectionFns.push(
(result) => {
@ -537,6 +540,7 @@ export abstract class CascadeStore<ED extends EntityDict & BaseEntityDict> exten
Object.assign(projection, {
[`${attr}Id`]: 1,
});
assert(typeof projection2[attr] === 'object');
if (supportMtoJoin) {
if (!toModi) {
// 如果不是modi要保证外键没有空指针