Skip to content
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

Add failing test for issue #7062 - BasicEntityPersister confuses association types with PDO datatypes #7082

Merged
merged 2 commits into from
Feb 27, 2018

Conversation

mariusklocke
Copy link
Contributor

Providing a failing testcase as requested in issue #7062

@Ocramius
Copy link
Member

@mariusklocke maybe you intended to send this to 2.6?

@mariusklocke mariusklocke changed the base branch from master to 2.6 February 20, 2018 21:57
@mariusklocke
Copy link
Contributor Author

Changed to 2.6
Got a little confused when reading the contribution guidelines :)

Copy link
Member

@lcobucci lcobucci left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mariusklocke can you please combine the models in the test file just like https://github.com/doctrine/doctrine2/blob/30a063ef9d7b14d0c74a192d87dc31c600503a4b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH6531Test.php ?

This would also make things easier for us to review, you to fix coding standard issues using phpcbf, and also removes all the changes you've made in OrmFunctionalTestCase (which are not really necessary).

// Now try to read entities again and check if all changes have been made persistent correctly
/** @var Season $season */
$season = $this->_em->find(Season::class, self::SEASON_ID);
$this->assertInstanceOf(Season::class, $season);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use self::assert* instead since the method is static.

@mariusklocke
Copy link
Contributor Author

Thanks for your quick feedback. Will do that in the next days.

@lcobucci lcobucci self-requested a review February 23, 2018 09:42
@lcobucci
Copy link
Member

lcobucci commented Feb 25, 2018

@mariusklocke @Ocramius wow, this is a tough one! The cause of the issue is that for some reason the ORM is not using the correct type for the ranking field (it's seems to be using `PDO::PARAM_INT) on the update query... I'll continue my investigation here


I just now realised that the whole thing was already described in the issue, stupid me 😂

@lcobucci lcobucci added this to the 2.6.1 milestone Feb 25, 2018
@mariusklocke
Copy link
Contributor Author

@lcobucci Did you read my analysis where i reported the issue? Can you state if my assumptions there are correct?

Copy link
Member

@lcobucci lcobucci left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mariusklocke I've changed things a bit in the test to always fetch things from the database, just to ensure that things are isolated.

The fix itself was pretty simple (with a little help from @guilhermeblanco).

Thanks for your contribution!

@lcobucci
Copy link
Member

@lcobucci Did you read my analysis where i reported the issue? Can you state if my assumptions there are correct?

@mariusklocke I read it, after I've posted my comment... you're assumptions are indeed correct

@mariusklocke
Copy link
Contributor Author

I'm glad you found a fix. Debugging that took me a while :)

@lcobucci
Copy link
Member

@mariusklocke the only thing is that your mapping quite complex and it uncovers some scenarios that we haven't thought about (the fact that RankingPosition has Ranking as id, but that id is actually Season is making the IdentifierFlattener a bit crazy - only when running with L2C enabled)...

/**
* @Id
* @OneToOne(targetEntity=GH7062Season::class, inversedBy="ranking")
* @JoinColumn(name="season", referencedColumnName="id")
Copy link
Member

@lcobucci lcobucci Feb 25, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Ocramius @guilhermeblanco this test revealed a nice unrelated issue (when loading things with L2C the identifier flattener tries to use the column name in an array that doesn't have that index).
Forcing the entity to use the name of the field as the name of the column was the only way to isolate the issue that @mariusklocke described... what are your thoughts about this workaround?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lcobucci as long as we can open a new issue with the new problem, I'm good to isolate issues in 2 separate PRs. =)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@guilhermeblanco that's the idea

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that's a separate issue - let's not creep it into here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#7096 created to handle that

Copy link
Member

@Ocramius Ocramius left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine with the patch overall, but the test uses a DSL from a different domain, and that makes things quite complex to follow when reasoning about ORM details.

I'd rather get rid of all the public methods in these entities, and modify all states via public properties instead, making the classes ORM-naming-specific instead of flavored with Season and Team

mariusklocke and others added 2 commits February 26, 2018 14:39
Which was using the wrong way to fetch the field type and using the
association type instead of the column type.
@lcobucci
Copy link
Member

@Ocramius how about now?

@Ocramius
Copy link
Member

@lcobucci if the test still fails with the patch not applied, then 👍

I'd rather completely get rid of the team/season/etc thing...

@lcobucci
Copy link
Member

@lcobucci if the test still fails with the patch not applied, then 👍

@Ocramius it does fail.

I'd rather completely get rid of the team/season/etc thing...

I removed all the methods but decided to keep the whole thing due to the complicated setup of FKs (which is exactly what affects the bug).

@Ocramius
Copy link
Member

🚢

@Ocramius Ocramius merged commit 87ee409 into doctrine:2.6 Feb 27, 2018
@Ocramius
Copy link
Member

Btw, just noticed that recent patches aren't in 2.7. Will need to merge 2.6 up (not nice, but not as important as master right now)

@Ocramius Ocramius changed the title Add failing test for issue #7062 Add failing test for issue #7062 - BasicEntityPersister confuses association types with PDO datatypes Feb 27, 2018
@Ocramius
Copy link
Member

Also cherry-picking this into master

@Ocramius
Copy link
Member

Interestingly, the test passes on master without actually needing to apply the patch - accidentally fixed by fixing our mapping system :-)

Ocramius added a commit that referenced this pull request Feb 27, 2018
@Ocramius
Copy link
Member

In master as per bbc1ed9
In 2.7 as per 4f6d47b

maglnet pushed a commit to maglnet/doctrine2 that referenced this pull request Oct 10, 2018
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.

4 participants