fix(obligations_creation): Ensure license BeforeCreate hook runs only during creation (#121)#122
Conversation
72b1caf to
24a20e2
Compare
|
@deo002 , can you please review this pr ? |
|
Ideally, on obligation creation, the BeforeCreate hook(for Licenses) shouldn't run as the Licenses to be associated already exist and aren't new. A good approach would be to ensure BeforeCreate doesn't run in this case instead of adding a check in it. What do you suggest? However, on creating an obligation, GORM treats the licenses in o.Licenses array as new records and creates them if they do not already exist instead of treating them as existing records. This triggers the BeforeCreate hook for licenses. Can we first create the obligation and then associate existing licenses to it via associations? This way, BeforeCreate hook wont run. |
24a20e2 to
e5c3664
Compare
|
I am really sorry for not checking this PR until now Chayan. Could you rebase it with the current main or open a new PR, which ever one is easier? Thanks! |
…sology#121) Signed-off-by: chayandass <daschayan8837@gmail.com>
ff48272 to
446cc07
Compare
|
Closing in favour of #149 |
Problem
When creating an Obligation with
shortnames, theBeforeCreatehook is triggered due to the licensedb being associated with shortames. However, this leads to ausername not found in contexterrorChanges
BeforeCreatehook to run only during creation by adding check.Submitter Checklist
References
no problem on creation of obligation

on problem on creation of license