Skip to content

Commit 9acc70d

Browse files
authored
fix: support array-type arg in QB variadic calls (#11242)
1 parent 5a40b99 commit 9acc70d

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

src/Query/Expr/Base.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,12 @@
77
use InvalidArgumentException;
88
use Stringable;
99

10+
use function array_key_exists;
1011
use function count;
1112
use function get_debug_type;
1213
use function implode;
1314
use function in_array;
15+
use function is_array;
1416
use function is_string;
1517
use function sprintf;
1618

@@ -33,6 +35,10 @@ abstract class Base implements Stringable
3335

3436
public function __construct(mixed $args = [])
3537
{
38+
if (is_array($args) && array_key_exists(0, $args) && is_array($args[0])) {
39+
$args = $args[0];
40+
}
41+
3642
$this->addMultiple($args);
3743
}
3844

tests/Tests/ORM/QueryBuilderTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,15 @@ public function testSimpleSelect(): void
8080
$this->assertValidQueryBuilder($qb, 'SELECT u.id, u.username FROM Doctrine\Tests\Models\CMS\CmsUser u');
8181
}
8282

83+
public function testSimpleSelectArray(): void
84+
{
85+
$qb = $this->entityManager->createQueryBuilder()
86+
->from(CmsUser::class, 'u')
87+
->select(['u.id', 'u.username']);
88+
89+
$this->assertValidQueryBuilder($qb, 'SELECT u.id, u.username FROM Doctrine\Tests\Models\CMS\CmsUser u');
90+
}
91+
8392
public function testSimpleDelete(): void
8493
{
8594
$qb = $this->entityManager->createQueryBuilder()

0 commit comments

Comments
 (0)