You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When updating a parentRecords parent, the resulting parents of the parentRecord is incorrect
Expected Behavior
when updating a parent records parent to a new grandParentRecord i expect the result value of the parentRecords parents to equal [parentRecord, newGrandParentRecord]
Actual Behavior
when updating a parent records parent to a new grandParentRecord the result value of the parentRecords parents equal [parentRecord, oldGrandParentRecord, newgrandParentRecord]
I am currently using a work around for now. Since the error seems to only occur during an update i call a helper function to manually alter the closure table during an update mutation.
public async updateTreeParent(childEntity: Entity, input: Update, manager: EntityManager): Promise<Entity> {
const existingRecord = await manager.query(`SELECT 1 FROM ${this.closureTableName} WHERE id_descendant = '${childEntity.id}' AND id_ancestor = '${input.parentId}'`);
if (!existingRecord.length) await manager.query(`UPDATE ${this.closureTableName} SET id_ancestor = '${input.parentId}' WHERE id_descendant = '${childEntity.id}' AND id_ancestor = '${childEntity.parentId}'`);
else {
await manager.query(`DELETE FROM ${this.closureTableName} WHERE id_descendant = '${childEntity.id}' AND id_ancestor = '${childEntity.parentId}'`);
}
return childEntity;
}
Issue description
When updating a parentRecords parent, the resulting parents of the parentRecord is incorrect
Expected Behavior
when updating a parent records parent to a new grandParentRecord i expect the result value of the parentRecords parents to equal
[parentRecord, newGrandParentRecord]
Actual Behavior
when updating a parent records parent to a new grandParentRecord the result value of the parentRecords parents equal
[parentRecord, oldGrandParentRecord, newgrandParentRecord]
Steps to reproduce
My Environment
Additional Context
I am currently using a work around for now. Since the error seems to only occur during an update i call a helper function to manually alter the closure table during an update mutation.
my entity extends this base entity
Relevant Database Driver(s)
Are you willing to resolve this issue by submitting a Pull Request?
Yes, I have the time, but I don't know how to start. I would need guidance.
The text was updated successfully, but these errors were encountered: