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

[DoctrineBridge] indexBy could reference to association columns#38628

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
nicolas-grekas merged 2 commits intosymfony:3.4fromjuanmiguelbesada:issue-37982
Nov 9, 2020

Conversation

@juanmiguelbesada
Copy link
Contributor

QA
Branch?3.4
Bug fix?yes
New feature?no
Deprecations?no
TicketsFix#37982
LicenseMIT
Doc PR-

This is my approach to solve#37982. It partials reverts@xabbuh PR#38604

This is my first Symfony contribution, so please, tell me if I need to do something more or something is wrong.

Also, this bug affects 4.x and 5.x versions. I think merging in this branches is done automatically. If not, please tell me.

Thanks you

Nyholm and lchrusciel reacted with heart emoji
$associationMapping =$subMetadata->getAssociationMapping($fieldName);

/** @var ClassMetadataInfo $subMetadata */
$indexProperty =$subMetadata->getSingleAssociationReferencedJoinColumnName($fieldName);
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't we add some kind of check that the column name used here is in fact the join column?

@nicolas-grekas
Copy link
Member

Please check#38861 also.

@juanmiguelbesada
Copy link
ContributorAuthor

I will take a look

nicolas-grekas and tannyl reacted with thumbs up emoji

Copy link
Member

@jderussejderusse left a comment

Choose a reason for hiding this comment

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

People at Doctrine says it could/shoud be a property (doctrine/orm#8018 (comment))
Which leads to issue in Symfony:#38861

Given this is not clear, I suggest to supports both cases:

  • IndexBy point to a property
  • IndexBy point to a column_name

@bwach
Copy link

bwach commentedOct 30, 2020
edited
Loading

People at Doctrine says it could/shoud be a property (doctrine/orm#8018 (comment))
Which leads to issue in Symfony:#38861

Given this is not clear, I suggest to supports both cases:

* IndexBy point to a property* IndexBy point to a column_name

This is also reflected in description for ClassMetadataInfo which we use here (depending on how you understand the whole paragraph)

https://github.com/doctrine/orm/blob/c1943624ab1260c629316bab104dc5130c060154/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php#L516

describing "indexBy" as:

Specification of a field on target-entity that is used to index the collection by.

So it should be one of the fields on the entity, not a column.
I guess the problem in the long run is that doctrine doesn't validate this, so you can type anything into the "indexBy" annotation and it will still work.

@xabbuh
Copy link
Member

How does Doctrine behave for one or the other? Does it ignore the attribute? Does it try to map the column to a property or vice versa?

@juanmiguelbesadajuanmiguelbesadaforce-pushed theissue-37982 branch 2 times, most recently from6b58fa4 toa0b6778CompareNovember 5, 2020 06:56
@juanmiguelbesada
Copy link
ContributorAuthor

PR updated fixing#38861 (I hope) and adding tests

Copy link
Member

@xabbuhxabbuh left a comment

Choose a reason for hiding this comment

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

LGTM

@carsonbotcarsonbot changed the title[DoctrineBridge] indexBy could reference to association columns[DoctrineBridge] indexBy could reference to association columnsNov 9, 2020
@nicolas-grekas
Copy link
Member

Thank you@juanmiguelbesada.

@nicolas-grekasnicolas-grekas merged commit6724ca7 intosymfony:3.4Nov 9, 2020
@fabpotfabpot mentioned this pull requestNov 10, 2020
@fabpotfabpot mentioned this pull requestNov 27, 2020
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@xabbuhxabbuhxabbuh approved these changes

@dunglasdunglasAwaiting requested review from dunglasdunglas is a code owner

@jderussejderusseAwaiting requested review from jderusse

Assignees

No one assigned

Projects

None yet

Milestone

3.4

Development

Successfully merging this pull request may close these issues.

6 participants

@juanmiguelbesada@nicolas-grekas@bwach@xabbuh@jderusse@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp