Skip to content

Commit

Permalink
fix: add missing meta table join
Browse files Browse the repository at this point in the history
  • Loading branch information
williarin committed Jul 25, 2024
1 parent 3e1f8d8 commit 17b7f8f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/Bridge/Repository/AbstractEntityRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -825,6 +825,7 @@ private function selectColumns(QueryBuilder $queryBuilder, array $extraFields, S
if (in_array($column, $extraFields, true)) {
$mappedMetaKey = $this->getMappedMetaKey($column);
$selects[] = select_from_eav($column, $mappedMetaKey);
$this->joinSelfMetaTable($queryBuilder);
} elseif (str_starts_with($column, 'MAX(')) {
$selects[] = $column;
$this->joinSelfMetaTable($queryBuilder);
Expand Down
10 changes: 10 additions & 0 deletions test/Test/Bridge/Repository/ProductRepositoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -552,4 +552,14 @@ public function testOperatorIsNotNullNested(): void
self::assertContainsOnlyInstancesOf(Product::class, $products);
self::assertEquals([17, 20, 23], array_column($products, 'id'));
}

public function testSelectEntityFieldWithoutQueryingIt(): void
{
$product = $this->repository->findOneBy([
new SelectColumns(['id', 'sku']),
'post_title' => 'Hoodie',
]);

$this->assertSame('woo-hoodie', $product->sku);
}
}

0 comments on commit 17b7f8f

Please sign in to comment.