mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
Mapping discrepancy for ManyToOne with new inference #6774
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 @TristanPouliquen on GitHub (Jun 30, 2021).
Hello,
I've come across a discrepancy in the SQL produced by Doctrine for ManyToOne annotations. As stated in the official documentation, the
JoinColumnshould infer thenullablefrom the attribute type definition.However, this is actually not the case.
I've created a minimal reproduction case in this repository.
As you can see in EntityC, I've defined one
ManyToOnewith PHP7.4 typed attributes and the other without it.In the dump of my SQL schema, you can see that the SQL statements for both fields are not the same, when they should normally be.
The statement for the relationship with EntityA, defined with a typed attribute, has a
DEFAULT NULLclause that should not happen.How can I help going ahead in fixing this?
@TristanPouliquen commented on GitHub (Jul 1, 2021):
There also seems to have an error in the inference of the nullable attribute for simple types. I have updated my reproduction to insert a typed nullable string attribute, that generates a VARCHAR NOT NULL in my Doctrine schema.
@greg0ire commented on GitHub (Jul 1, 2021):
Finding who introduced the new inference and it which PR would help finding the best people to help with this `git log -S 'some string' should help with this.
@mbabker commented on GitHub (Jul 1, 2021):
Nullable inference was backed out in https://github.com/doctrine/orm/pull/8732 due to B/C issues.
@TristanPouliquen commented on GitHub (Jul 1, 2021):
Ah, thanks to both of you. I had tried to look for similar issues but did not come across these ones.
Too bad it has been reversed, but I understand the BC point of view. I'll wait for the 3.x to remove these last bits of redundant annotations!
Cheers!