-
-
Notifications
You must be signed in to change notification settings - Fork 848
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
Ask target entity for its identifier instead of hardcoding to id #1810
Conversation
@@ -272,7 +272,8 @@ protected function filterProperty(string $property, $value, QueryBuilder $queryB | |||
|
|||
if ($metadata->isCollectionValuedAssociation($association)) { | |||
$associationAlias = QueryBuilderHelper::addJoinOnce($queryBuilder, $queryNameGenerator, $alias, $association); | |||
$associationField = 'id'; | |||
$targetEntityMetaData = $this->getClassMetadata($metadata->getAssociationMapping($association)['targetEntity']); | |||
$associationField = $targetEntityMetaData->getIdentifier()[0]; |
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.
it'll not work with mutliple identifiers but I guess it's better then before haha.
I'm 👍 for the change
hardcoded |
Just found another issue. Also the IRI conversion was hardcoded to |
* | ||
* @return mixed | ||
*/ | ||
protected function getIdFromValue(string $value) | ||
protected function getIdFromValue(string $value, string $identifier = 'id') |
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.
Unfortunately, it's a BC break http://symfony.com/doc/current/contributing/code/bc.html#changing-classes
You'll have to use func_get_args
and throw a deprecation.
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.
Ah, I wasn't aware that this class is meant to be extended :-) I could also add a new getIdentifierFromValue()
and deprecate the old one?
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.
Yes
Could you please check why the tests are failling ? |
Oh, I missed them, sure! |
Hmm, no idea what's going on there, really. I'm not so much into the search filter, I just noticed it's hardcoded to the |
@Simperfit is #1844 a follow-up to this? |
I'm closing this because #1844 is the right approach. |
I have absolutely no clue if this is a correct fix but I wanted to open a PR here to have someone point me into the right direction. The problem is that the
SearchFilter
does an INNER JOIN for relations and addsWHERE $associationAlias.id
hardcoded to the search query. However, my target entity does not haveid
as its identifier. I named the columnuuid
.