Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Doctrine Bridge] fix UniqueEntityValidator for composite object primary keys#21288

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
fabpot merged 2 commits intosymfony:3.1fromdmaicher:unique-entity-pk-objects
Jan 16, 2017

Conversation

@dmaicher
Copy link
Contributor

@dmaicherdmaicher commentedJan 14, 2017
edited by nicolas-grekas
Loading

QA
Branch?master / 3.1
Bug fix?yes
New feature?no
BC breaks?no
Deprecations?no
Tests pass?yes (fail on php 7.1 unrelated?)
Fixed tickets#21274
LicenseMIT
Doc PR-

This PR fixes an issue with the UniqueEntityValidator in case the entity being validated uses a composite primary key via relations to other entities whose classes do not have a__toString method.

$identifiers =array_map(function ($identifier)use ($em) {
// identifiers can be objects (without any __toString method) if its a composite PK
if (is_object($identifier) && !method_exists($identifier,'__toString')) {
returnsprintf('(%s)',$this->buildInvalidValueString($em,$em->getClassMetadata(get_class($identifier)),$identifier));
Copy link
ContributorAuthor

@dmaicherdmaicherJan 14, 2017
edited
Loading

Choose a reason for hiding this comment

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

is it safe to use the same object manager here for the related class? Not sure if Doctrine supports relations between classes of different object managers?


$this->validator->validate($newEntity,$constraint);

$expectedValue ='Object of class "Symfony\Bridge\Doctrine\Tests\Fixtures\CompositeObjectNoToStringIdEntity" identified by "(Object of class "Symfony\Bridge\Doctrine\Tests\Fixtures\SingleIntIdNoToStringEntity" identified by "1"), (Object of class "Symfony\Bridge\Doctrine\Tests\Fixtures\SingleIntIdNoToStringEntity" identified by "2")"';
Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

should we find a shorter way to build this message? 😝

@dmaicher
Copy link
ContributorAuthor

@HeahDude as you added this code (40c0c52) what do you think about this?

@HeahDude
Copy link
Contributor

I've discussed this PR with@dmaicher indmaicher#1, which is now merged.

This looks good to me.

ping@symfony/deciders

@nicolas-grekasnicolas-grekas changed the title[Doctrine Bridge] fix UniqueEntityValidator for composite object prim…[Doctrine Bridge] fix UniqueEntityValidator for composite object primary keysJan 16, 2017
@nicolas-grekas
Copy link
Member

Failure looks related to me (not the messages about getMock, but the one about CompositeObjectNoToStringIdEntity) - maybe a composer.json update needed somewhere?

@HeahDude
Copy link
Contributor

@nicolas-grekas I've openeddmaicher#2 which seems to have fixed the tests, waiting for@dmaicher to merge it.

@nicolas-grekas
Copy link
Member

nicolas-grekas commentedJan 16, 2017
edited
Loading

@dmaicher can you please squash the history? We can't merge (nor don't want to :) ) merge PRs with merges inside.

@nicolas-grekas
Copy link
Member

(maybe keep just two commits, one for you and one for@HeahDude with rebase -i ?)

@dmaicher
Copy link
ContributorAuthor

@nicolas-grekas sure 😉 Let's wait for the build and hope its fixed

@HeahDude
Copy link
Contributor

Green 🎉

dmaicher reacted with hooray emoji

@dmaicherdmaicherforce-pushed theunique-entity-pk-objects branch fromd942a96 tob3ced86CompareJanuary 16, 2017 14:01
@dmaicher
Copy link
ContributorAuthor

Done 😉

HeahDude reacted with thumbs up emoji

@fabpot
Copy link
Member

I've not checked, but don't we have the same issue in 2.7 and 2.8?

@HeahDude
Copy link
Contributor

@fabpot This fix is related to a feature introduced in 3.1#15279, and not enough fixed by#19227 (missing composite identifiers handling, provided here).

@fabpot
Copy link
Member

Thank you@dmaicher.

@fabpotfabpot merged commitb3ced86 intosymfony:3.1Jan 16, 2017
fabpot added a commit that referenced this pull requestJan 16, 2017
…object primary keys (dmaicher, HeahDude)This PR was merged into the 3.1 branch.Discussion----------[Doctrine Bridge] fix UniqueEntityValidator for composite object primary keys| Q             | A| ------------- | ---| Branch?       | master / 3.1| Bug fix?      | yes| New feature?  |no| BC breaks?    | no| Deprecations? |no| Tests pass?   | yes (fail on php 7.1 unrelated?)| Fixed tickets |#21274| License       | MIT| Doc PR        | -This PR fixes an issue with the UniqueEntityValidator in case the entity being validated uses a composite primary key via relations to other entities whose classes do not have a `__toString` method.Commits-------b3ced86 [DoctrineBridge] Fixed invalid unique value as composite key5aadce3 [Doctrine Bridge] fix UniqueEntityValidator for composite object primary keys
@fabpotfabpot mentioned this pull requestJan 28, 2017
@fabpotfabpot mentioned this pull requestFeb 6, 2017
@dmaicherdmaicher deleted the unique-entity-pk-objects branchAugust 23, 2018 12:28
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Projects

None yet

Milestone

3.1

Development

Successfully merging this pull request may close these issues.

5 participants

@dmaicher@HeahDude@nicolas-grekas@fabpot@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp