mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
ManyToOne two-columns (combined primary key) self-referencing association. Can't insert entry #5315
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @pozdeiev on GitHub (Nov 4, 2016).
Originally assigned to: @lcobucci on GitHub.
PHP 5.6, Doctrine ORM 2.5.5.
Hello! I got trouble with the inserting/updating Entity which has OneToMany two-columns self-referencing association.
I have table
Shopwith shops and tableGroupwith groups. Every shop has its own set of groups. Every group can has one parent group within the same shop.Model:
Works fine when I insert with the
$parentspecified, but get error, if$parent=null(case of a root group):I can't understand what is wrong. Why
shop=null? I'm sure that$shopis passing correct to the__construct()(checked it).Same thing if I try to update an existing row by setting
$parent=null- Doctrine 2 will try to setshop=nulltoo.Please help. Thanks in advance.
@Ocramius commented on GitHub (Nov 5, 2016):
@mittahru weird edge case, but can you eventually abstract it into a test case? See
d3f6c5ec70/tests/Doctrine/Tests/ORM/Functional/Ticketfor examples.@pozdeiev commented on GitHub (Nov 5, 2016):
@Ocramius, you mean this?
DDC6117Test.php@Ocramius commented on GitHub (Nov 6, 2016):
Perfect, thanks!
On 5 Nov 2016 17:39, "Dmitry Pozdeiev" notifications@github.com wrote:
@pozdeiev commented on GitHub (Sep 27, 2017):
This issue still missing tests?
@Ocramius commented on GitHub (Sep 27, 2017):
No, lemme remove the label. It wasn't picked up by anyone though.
@lcobucci commented on GitHub (Nov 26, 2017):
@mittahru the problem is happening because your mapping is incorrect... since
$parentis a nullable field the join columns should also be nullable (and they should not use the same columns of the entity itself), like:With mapping above the test bellow passes with no issues:
@lcobucci commented on GitHub (Nov 26, 2017):
I'll close this ticket as
Invaliddue to the given explanation.@pozdeiev commented on GitHub (Nov 27, 2017):
@lcobucci thanks a lot!