-
-
Notifications
You must be signed in to change notification settings - Fork 84
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
Null value for inversed one-to-one relation (v2.3.1) #749
Comments
Yeah, that's what I saw from your reproducer. I've finally found a viable solution for this "one to one inversed" problem, just need to polish things up :)
Thanks, I'd rather to keep both issues open until I'm not 100% sure they are duplicates (we'll see if the patch fixes both issues!) |
@florian-bailly PR #755 fixes your issue, I just verified with your reproducer :) |
@nikophil indeed it's fixed for the reproducer case :) However, I still have the null issue on my project on another entity. I'll try to make a reproducer for that case. |
yeah, if you can upgrade your reproducer that would be perfect :) |
@nikophil in the docs, you show examples like this: $post = PostFactory::createOne(); // instance of Proxy
CommentFactory::createOne(['post' => $post]); But what I want is to use just this: PostFactory::createOne(); And, inside the protected function defaults(): array|callable
{
return [
// ...
'comments' => [CommentFactory::createOne()],
];
} This is not working as expected and in the error message I see something about null values for non-nullable fields. I was going to create a new issue ... but then I found this issue and I don't know if it's the same issue reported here or not. Thanks! |
@javiereguiluz is the project where you have the problem open source? I'd really like to tackle this problem. More over your problem is about |
@nikophil I think you have fixed the issue regarding the 1:1 since the issues I have are not for the same kind of relations. I've updated the reproducer (sorry for the entity names, they are poorly chosen). The error you should have is:
and using xdebug I see that on the accountMultipleSettings table, the foo relation is not set... though in the test it's set explicitly. Also, I'm wondering why the Foo entity is persisted twice. Shouldn't the Finally, how those regressions where possible between the v1 and the v2. Are there missing tests? |
thanks, that will be super helpful
I still don't know, I have to deep dive into it 😬
yeah, there are literally tons of different use cases in the wild, and Foundry v2 got a nearly full rewrite |
this was challenging, but I finally tackled your problem! By the way, still related to inversed one-to-one... I don't know how Foundry 1 was actually better shaped for this kind of things 🤷 |
hi @nikophil , Well done! I've tested the fix in my project, but I get the following error:
Let me know if it's normal as the v2 is more strict or if you think it's a bug. |
gosh, this is a never ending story 😞 I cannot know whether the problem comes from Foundry or your code base only based on this error... The error is strange, because every entity created by Foundry is given to |
@nikophil I managed to reproduce the error but after cleaning some files to make a simple reproducer, I came accross another error and I can't go back. I updated the reproducer, hopefully after this last is fixed I'll be able to get back the one we're looking for :) |
did you try this PR, which is not yet merged? it is the one which fixed your previous problem. Using it solves the problem in your reproducer :) |
@nikophil That's weird because I was on the PR 775 but it looks like a change was added after my reproducer. Anyway, I confirm the case of the reproducer no 3 is fixed. BUT I still have the same error for another case (seems again a 1:1 with other relations). I'll try to make a reproducer ;) |
Yeah, there were some changes on the PR indeed, but before I saw your new reproducer 😅 Thanks for your help, though, very much appreciated 🙏 |
I'm upgrading Foundry on my project to use the v2.
However, it seems like the inversed relation is not auto filled, resulting in a null value (and violating the constraint on insertion), which was not the case before.
I thought this issue would fix ours but it's not the case (since the latest version including the fix is not working).
For the reproducer, I created an Account and AccountSetting entity.
When trying to create an Account with a specified AccountSetting, the account property of the accountSetting is not filled (it is null).
Link to the reproducer test
The text was updated successfully, but these errors were encountered: