diff --git a/src/Bridge/Repository/AbstractEntityRepository.php b/src/Bridge/Repository/AbstractEntityRepository.php index caecaf1..df813c1 100644 --- a/src/Bridge/Repository/AbstractEntityRepository.php +++ b/src/Bridge/Repository/AbstractEntityRepository.php @@ -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); diff --git a/test/Test/Bridge/Repository/ProductRepositoryTest.php b/test/Test/Bridge/Repository/ProductRepositoryTest.php index c5b2ff1..93581d1 100644 --- a/test/Test/Bridge/Repository/ProductRepositoryTest.php +++ b/test/Test/Bridge/Repository/ProductRepositoryTest.php @@ -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); + } }