mirror of
https://github.com/gristlabs/grist-core.git
synced 2024-10-27 20:44:07 +00:00
(core) Fix TypeORM failure when unremoving entities
Summary: When `save` was called without any modifications to the entity, TypeORM would throw an error. This could sometimes occur if an entity was unremoved by two different clients with the same application state. We now avoid calling `save` if a document or workspace is already unremoved. Test Plan: Manual. Reviewers: jarek Reviewed By: jarek Differential Revision: https://phab.getgrist.com/D4365
This commit is contained in:
parent
8402cccd7e
commit
c824964152
@ -4326,8 +4326,10 @@ export class HomeDBManager extends EventEmitter {
|
|||||||
});
|
});
|
||||||
const workspace: Workspace = this.unwrapQueryResult(await verifyEntity(wsQuery));
|
const workspace: Workspace = this.unwrapQueryResult(await verifyEntity(wsQuery));
|
||||||
workspace.removedAt = removedAt;
|
workspace.removedAt = removedAt;
|
||||||
const data = await manager.save(workspace);
|
await manager.createQueryBuilder()
|
||||||
return {status: 200, data};
|
.update(Workspace).set({removedAt}).where({id: workspace.id})
|
||||||
|
.execute();
|
||||||
|
return {status: 200, data: workspace};
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4347,8 +4349,10 @@ export class HomeDBManager extends EventEmitter {
|
|||||||
await this._checkRoomForAnotherDoc(doc.workspace, manager);
|
await this._checkRoomForAnotherDoc(doc.workspace, manager);
|
||||||
}
|
}
|
||||||
doc.removedAt = removedAt;
|
doc.removedAt = removedAt;
|
||||||
const data = await manager.save(doc);
|
await manager.createQueryBuilder()
|
||||||
return {status: 200, data};
|
.update(Document).set({removedAt}).where({id: doc.id})
|
||||||
|
.execute();
|
||||||
|
return {status: 200, data: doc};
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user