-
-
Notifications
You must be signed in to change notification settings - Fork 253
Description
Description
In the eager creation process, the AssociationsAfterCreatable in the Create method do not attempt to fall back to the DB store if a transaction is not found: https://github.com/gobuffalo/pop/blob/master/executors.go#L263
In the AssociationsCreatable block this does happen: https://github.com/gobuffalo/pop/blob/master/executors.go#L281
I was wondering if this is intentional (maybe to enforce atomicity of that type of association) or if that section should fall back to the store. Right now, it just silently continues and the associations aren't created. If this is intentional, maybe an error or log would be appropriate, because right now it doesn't do what the caller is intending by adding Eager
Steps to Reproduce the Problem
Try to eager create a model with has_many associations without a transaction block. This isn't an exact replica of what I'm working with locally since I'm using my own models.
Using https://github.com/gobuffalo/pop/blob/master/executors_test.go#L420.
user := User{
Name: nulls.NewString("Mark 'Awesome' Bates"),
Books: Books{{Title: "Pop Book", Description: "Pop Book", Isbn: "PB1"}},
}
err := connection.Eager().Create(&user) // where connection here is a *pop.Connection not in a transaction
u := User{}
q := connection.Eager().Where("name = ?", "Mark 'Awesome' Bates")
err = q.First(&u) // u will not have books here
Expected Behavior
I would expect the association to be created or to get an error/log that it was not.
Actual Behavior
The association is not created and it moves on silently.
Info
I'm using Pop V4.9.3