Fix typed properties for default metadata (#7939)#8589
Fix typed properties for default metadata (#7939)#8589beberlei merged 13 commits intodoctrine:2.9.xfrom
Conversation
beberlei
left a comment
There was a problem hiding this comment.
This is great work, thank you very much! I have only a few comments.
| if ($this->isTypedProperty($mapping['fieldName'])) { | ||
| $mapping = $this->validateAndCompleteTypedAssociationMapping($mapping); | ||
| } elseif (isset($mapping['joinColumns'])) { | ||
| foreach ($mapping['joinColumns'] as &$joinColumn) { |
There was a problem hiding this comment.
I believe this will not work here, because _validateAndCompleteAssociationMapping is called before the code for setting default joinColumns is called in _validateAndCompleteOneToOneMapping.
I believe, you need to put this code into _validateAndCompleteOneToOneMapping, it is also used for ManyToOne, and those two assocations are the only two that we are interested in completing anyways.
Otherwise it will not work for the case where you only specify @ManyToOne but not a corresponding @JoinColumn.
There was a problem hiding this comment.
You are right and adding tests for @ManyToOne without joinColumn uncovered it. I have fixed it exactly as suggested.
| $columnAnnot = $this->reader->getPropertyAnnotation($property, Mapping\Column::class); | ||
| if ($columnAnnot) { | ||
| if ($columnAnnot->type === null) { | ||
| throw MappingException::propertyTypeIsRequired($className, $property->getName()); |
There was a problem hiding this comment.
is this method still used anywhere else? otherwise we can @deprecated it in MappingException.
There was a problem hiding this comment.
It seems it is not. I have added @deprecated
| * @OneToOne(cascade={"persist"}, orphanRemoval=true) | ||
| * @JoinColumn | ||
| */ | ||
| #[ORM\OneToOne(cascade: ["persist"], orphanRemoval: true), ORM\JoinColumn] |
There was a problem hiding this comment.
Please add another ManyToOne association to another email that does not define a join column.
There was a problem hiding this comment.
Great suggestion - it have shown a case not covered before and failing due to ManyToOne constructor dependency and wrong place of nullable checks. Fixed :)
86a114f to
d14d0a2
Compare
|
I have rebased and fix mentioned problems. Some tests now fail (despite showing |
|
@Lustmored that is a serious heisenbug, can reproduce locally unless I poke Xdebug at it, then it succeeds suddenly. Will investigate. It fails on 2.9.x as well. |
|
For some unclear reason, sometimes the CommitOrderCalculator changes the order of |
|
Ah of course it happens because of this change: https://github.com/doctrine/orm/pull/8589/files#diff-20cad4158379b4e6d3f30045b627fd986d0b238212c8b0318bbfca13d09f0d3dR44 |
330ce2a to
ddcc61c
Compare
…rderTest to circumvent new CommitOrderCalculator bug.
fixes lowest tests see doctrine/orm#8589 nullable default value changes and breaks our GraphQl schema
fixes lowest tests see doctrine/orm#8589 nullable default value changes and breaks our GraphQl schema
This is continuation of work from #7939. Tests for real life scenarios were missing therefore inheritance from typed properties wasn't running with metadata drivers.
This PR introduces such tests, adds metadata to test object for all drivers and makes small changes in drivers to adapt. Most needed changes were changing default value to null or removing
requiredfrom not required XML attributes.