server icon indicating copy to clipboard operation
server copied to clipboard

BUG: usage of new on entities resulting in orphaned data

Open techsmyth opened this issue 11 months ago • 1 comments

Describe the bug Creating a new entity such as new InnovationFlow() results in the creation of all associated child entities, including in this case Profile. The Profile entity is then separately created later, resulting in an orphaned Profile entry.

To Reproduce Steps to reproduce the behavior:

  1. Look at log files when creating a new InnovationFlow.

Expected behavior To be discussed

Additional info

Is it related to the field, i.e. Profile, in this case being declared as required (!) on the entity?

This approach of "new" to create entities happens in multiple other places, e.g. post template, ...

techsmyth avatar Mar 03 '24 11:03 techsmyth

Using "new" isn't the problem because it's not saving to the database. The issue here is we are creating and saving a profile before saving the innovation flow. If the innovation flow fails somewhere between creating the profile and saving the innovation flow we are going to end un with an orphaned profile. This is an issue we have with our create and delete code patterns. If the deletion breaks at some point while deleting relations we also end up with orphaned data.

alstojanovic avatar Mar 04 '24 16:03 alstojanovic