-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Fix typed properties for default metadata (#7939) #8589
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great work, thank you very much! I have only a few comments.
@@ -1642,6 +1642,14 @@ protected function _validateAndCompleteAssociationMapping(array $mapping) | |||
|
|||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right and adding tests for @ManyToOne
without joinColumn
uncovered it. I have fixed it exactly as suggested.
@@ -327,10 +327,6 @@ public function loadMetadataForClass($className, ClassMetadata $metadata) | |||
// @Column, @OneToOne, @OneToMany, @ManyToOne, @ManyToMany | |||
$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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this method still used anywhere else? otherwise we can @deprecated
it in MappingException
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems it is not. I have added @deprecated
public float $float; | ||
|
||
/** | ||
* @OneToOne(cascade={"persist"}, orphanRemoval=true) | ||
* @JoinColumn | ||
*/ | ||
#[ORM\OneToOne(cascade: ["persist"], orphanRemoval: true), ORM\JoinColumn] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add another ManyToOne
association to another email that does not define a join column.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
required
from not required XML attributes.