Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[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

Merged
merged 1 commit into from
Mar 18, 2018

Conversation

fancyweb
Copy link
Contributor

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

@@ -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)) {
Copy link
Contributor Author

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)) {
Copy link
Contributor Author

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.

@nicolas-grekas nicolas-grekas added this to the 2.7 milestone Mar 16, 2018
@fancyweb
Copy link
Contributor Author

fancyweb commented Mar 16, 2018

If checking the public property is not clean enough, there are other ways of doing it.

Copy link
Contributor

@Tobion Tobion left a 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

@fabpot
Copy link
Member

fabpot commented Mar 18, 2018

Thank you @fancyweb.

@fabpot fabpot merged commit f656dc2 into symfony:2.7 Mar 18, 2018
fabpot added a commit that referenced this pull request Mar 18, 2018
… 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 fancyweb deleted the doctrine-orm-type-guesser-has-field branch March 18, 2018 19:44
@pink6440
Copy link

@fancyweb nice and quick work ! thanks !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants