diff --git a/src/Mapper/Dbal/QueryBuilderHelper.php b/src/Mapper/Dbal/QueryBuilderHelper.php index a0f41f53..178d850b 100644 --- a/src/Mapper/Dbal/QueryBuilderHelper.php +++ b/src/Mapper/Dbal/QueryBuilderHelper.php @@ -128,7 +128,7 @@ private function normalizeAndAddJoins(array $levels, $sourceEntity, QueryBuilder $builder->leftJoin( $sourceAlias, - $joinTable, + "[$joinTable]", self::getAlias($joinTable), "[$sourceAlias.$sourceColumn] = [$joinTable.$inColumn]" ); @@ -148,7 +148,7 @@ private function normalizeAndAddJoins(array $levels, $sourceEntity, QueryBuilder $builder->leftJoin( $sourceAlias, - $targetTable, + "[$targetTable]", $targetAlias, "[$sourceAlias.$sourceColumn] = [$targetAlias.$targetColumn]" ); diff --git a/tests/cases/unit/Mapper/Dbal/QueryBuilderHelperTest.phpt b/tests/cases/unit/Mapper/Dbal/QueryBuilderHelperTest.phpt index 64d67e7a..692f04f7 100644 --- a/tests/cases/unit/Mapper/Dbal/QueryBuilderHelperTest.phpt +++ b/tests/cases/unit/Mapper/Dbal/QueryBuilderHelperTest.phpt @@ -100,7 +100,7 @@ class QueryBuilderHelperTest extends TestCase $this->entityMetadata->shouldReceive('getProperty')->once()->with('name')->andReturn(new PropertyMetadata()); $this->reflection->shouldReceive('convertEntityToStorage')->once()->with(['name' => NULL])->andReturn(['name' => NULL]); - $this->queryBuilder->shouldReceive('leftJoin')->once()->with('books', 'authors', 'translator', '[books.translator_id] = [translator.id]'); + $this->queryBuilder->shouldReceive('leftJoin')->once()->with('books', '[authors]', 'translator', '[books.translator_id] = [translator.id]'); $this->queryBuilder->shouldReceive('addOrderBy')->once()->with('[translator.name]'); $this->builderHelper->processOrderByExpression('this->translator->name', ICollection::ASC, $this->queryBuilder); @@ -155,9 +155,9 @@ class QueryBuilderHelperTest extends TestCase $this->reflection->shouldReceive('convertEntityToStorage')->once()->with(['name' => ['tag_name']])->andReturn(['name' => ['tag_name']]); - $this->queryBuilder->shouldReceive('leftJoin')->once()->with('authors', 'books', 'translatedBooks', '[authors.id] = [translatedBooks.translator_id]'); - $this->queryBuilder->shouldReceive('leftJoin')->once()->with('translatedBooks', 'books_x_tags', 'books_x_tags', '[translatedBooks.id] = [books_x_tags.book_id]'); - $this->queryBuilder->shouldReceive('leftJoin')->once()->with('books_x_tags', 'tags', 'tags_', '[books_x_tags.tag_id] = [tags_.id]'); + $this->queryBuilder->shouldReceive('leftJoin')->once()->with('authors', '[books]', 'translatedBooks', '[authors.id] = [translatedBooks.translator_id]'); + $this->queryBuilder->shouldReceive('leftJoin')->once()->with('translatedBooks', '[books_x_tags]', 'books_x_tags', '[translatedBooks.id] = [books_x_tags.book_id]'); + $this->queryBuilder->shouldReceive('leftJoin')->once()->with('books_x_tags', '[tags]', 'tags_', '[books_x_tags.tag_id] = [tags_.id]'); $this->queryBuilder->shouldReceive('andWhere')->once()->with('[tags_.name] IN %any', ['tag_name']); $this->builderHelper->processWhereExpression('this->translatedBooks->tags->name', ['tag_name'], $this->queryBuilder, $needDistinct);