mirror of
				https://github.com/gristlabs/grist-core.git
				synced 2025-06-13 20:53:59 +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)); | ||||
|       workspace.removedAt = removedAt; | ||||
|       const data = await manager.save(workspace); | ||||
|       return {status: 200, data}; | ||||
|       await manager.createQueryBuilder() | ||||
|         .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); | ||||
|       } | ||||
|       doc.removedAt = removedAt; | ||||
|       const data = await manager.save(doc); | ||||
|       return {status: 200, data}; | ||||
|       await manager.createQueryBuilder() | ||||
|         .update(Document).set({removedAt}).where({id: doc.id}) | ||||
|         .execute(); | ||||
|       return {status: 200, data: doc}; | ||||
|     }); | ||||
|   } | ||||
| 
 | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user