-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[DoctrineBridge] Don't rely on ClassMetadataInfo->hasField in DoctrineOrmTypeGuesser anymore #26567
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
[DoctrineBridge] Don't rely on ClassMetadataInfo->hasField in DoctrineOrmTypeGuesser anymore #26567
Conversation
…eOrmTypeGuesser anymore
@@ -95,7 +95,7 @@ public function guessRequired($class, $property) | |||
$classMetadata = $classMetadatas[0]; | |||
|
|||
// Check whether the field exists and is nullable or not | |||
if ($classMetadata->hasField($property)) { | |||
if (isset($classMetadata->fieldMappings[$property])) { | |||
if (!$classMetadata->isNullable($property) && Type::BOOLEAN !== $classMetadata->getTypeOfField($property)) { |
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.
isNullable
calls getFieldMapping
internally
@@ -143,7 +143,7 @@ public function guessMaxLength($class, $property) | |||
public function guessPattern($class, $property) | |||
{ | |||
$ret = $this->getMetadata($class); | |||
if ($ret && $ret[0]->hasField($property) && !$ret[0]->hasAssociation($property)) { | |||
if ($ret && isset($ret[0]->fieldMappings[$property]) && !$ret[0]->hasAssociation($property)) { |
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 one is not needed but I did it for consistency.
If checking the public property is not clean enough, there are other ways of doing it. |
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.
LGTM, thanks for the fix
Thank you @fancyweb. |
… in DoctrineOrmTypeGuesser anymore (fancyweb) This PR was merged into the 2.7 branch. Discussion ---------- [DoctrineBridge] Don't rely on ClassMetadataInfo->hasField in DoctrineOrmTypeGuesser anymore | Q | A | ------------- | --- | Branch? | 2.7 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #26543 | License | MIT | Doc PR | - Discussion and explanations in the linked issue #26543 Commits ------- f656dc2 [DoctrineBridge] Don't rely on ClassMetadataInfo->hasField in DoctrineOrmTypeGuesser anymore
@fancyweb nice and quick work ! thanks ! |
Discussion and explanations in the linked issue #26543