Skip to content

Commit

Permalink
bug #6330 [PATCH] Erroneously fails to search when table names match …
Browse files Browse the repository at this point in the history
…(ksn135)

This PR was squashed before being merged into the 4.x branch.

Discussion
----------

[PATCH] Erroneously fails to search when table names match

Fix #6329

Commits
-------

cf22ec8 [PATCH] Erroneously fails to search when table names match
  • Loading branch information
javiereguiluz committed Jul 9, 2024
2 parents 1e1a206 + cf22ec8 commit 5f4413d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Orm/EntityRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -262,13 +262,13 @@ private function getSearchablePropertiesConfig(QueryBuilder $queryBuilder, Searc
$associatedEntityAlias = $associatedPropertyName = '';
for ($i = 0; $i < $numAssociatedProperties - 1; ++$i) {
$associatedEntityName = $associatedProperties[$i];
$associatedEntityAlias = Escaper::escapeDqlAlias($associatedEntityName);
$associatedEntityAlias = Escaper::escapeDqlAlias($associatedEntityName).($i ?: '');

Check failure on line 265 in src/Orm/EntityRepository.php

View workflow job for this annotation

GitHub Actions / phpstan

Short ternary operator is not allowed. Use null coalesce operator if applicable or consider using long ternary.
$associatedPropertyName = $associatedProperties[$i + 1];

if (!\in_array($associatedEntityName, $entitiesAlreadyJoined, true)) {
if (!\in_array($associatedEntityAlias, $entitiesAlreadyJoined, true)) {
$parentEntityName = 0 === $i ? 'entity' : $associatedProperties[$i - 1];
$queryBuilder->leftJoin(Escaper::escapeDqlAlias($parentEntityName).'.'.$associatedEntityName, $associatedEntityAlias);
$entitiesAlreadyJoined[] = $associatedEntityName;
$entitiesAlreadyJoined[] = $associatedEntityAlias;
}

if ($i < $numAssociatedProperties - 2) {
Expand Down

2 comments on commit 5f4413d

@screenflavor
Copy link

Choose a reason for hiding this comment

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

This creates a new bug like '[Semantical Error] line 0, col 184 near '.feedContainer': Error: Identification Variable feed used in join path expression but was not defined before.' in case you have a field 'feed.feedContainer.title'
This is because the $parentEntityName has not implemented the number suffix.
It works if you add it in row 269: '$parentEntityName = 0 === $i ? 'entity' : $associatedProperties[$i - 1].((string)($i - 1));' <----------------

@ksn135
Copy link
Contributor

@ksn135 ksn135 commented on 5f4413d Jul 26, 2024

Choose a reason for hiding this comment

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

see PR #6388

Please sign in to comment.