mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
Cannot be null error when foreign key is last property #6249
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 @manseuk on GitHub (Jun 7, 2019).
Originally assigned to: @Ocramius on GitHub.
Bug Report
Summary
When using an entity with a composite key and another entity with a foreign key associated with the composite primary key, if the foreign key is set to NULL and its the last property then an error is encountered
Current behavior
How to reproduce
Create the following entities
Tenant.php
User.php
Page.php
Review.php
TestCommand.php
Running the command
TestCommandproduces the following errorUpdating the
Review.phpentity and moving the$tenantproperty to be last, like thisand then executing the same command fixes the issue
I have attached the project, running
composer installthenbin/console test:test-commandin its current state produces the errorExpected behavior
Command should execute successfully with the properties in the Review entity in any order
entitytest.zip
@Ocramius commented on GitHub (Jun 10, 2019):
Your mappings are not valid. Specifically:
You are re-using the
tenant_idcolumn for multiple associations, and that is not something the ORM supports.You will need separate
JoinColumndefinitions for these two associations.