-
-
Notifications
You must be signed in to change notification settings - Fork 75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Should object be scheduled for insert before afterInstantiate call ? #537
Comments
Hey @aegypius, just want to confirm, are the entities in your example above using cascade persist? I believe I chose to schedule the persist after One question about your code above, in your tests where persistence is disabled, how do you access the created Publish entity - is it like a one-to-one relationship? |
Hi @kbond ! Thanks for your reply my entities did not have cascade persist, I had this since and it worked.
I think my confusion tend to be from the fact that with doctrine we schedule persistence with In my mind, the
Yes I noticed this is an odd one 😄 ! In our project we use the proposal of @nikophil here #533. I should have said without "database persistence" relationship but I was'nt aware that this was not a standard foundry feature. |
I think the problem is more or less the same than #531 the class Program
{
public function __construct(
#[ORM\ManyToOne(targetEntity: Program::class)]
#[ORM\JoinColumn(nullable: false)]
private Program $program,
) {}
} Then we're using this trick with ProgramFactory::new()
->published()
->create() I'm pretty sure that this part of the problem will be fixed in Foundry 2 but I'm wondering if we cannot add a call to |
Hi,
@nikophil and I having an issue in one of my tests concerning the way
afterInstantiate
is handled.I struggle to understand what is meant to happen but my intuition is pointing to the moment where the "root" object is scheduled for insertion and the moment
afterInstantiate
callbacks are called.We cannot use
afterPersist
callbacks because some of our tests are preformed without persistence.To my understanding the process should be the following
But when we used this process in a factory like this :
Doctrine complains about not knowing the post
Ending with this ugly workaround that seems to do the trick
Is this the intended behavior that the root object is not yet scheduled for insert in this case ?
The text was updated successfully, but these errors were encountered: