Skip to content

Commit

Permalink
fix repeated QueryBuilder::from() call [closes #230]
Browse files Browse the repository at this point in the history
  • Loading branch information
hrach committed Mar 8, 2024
1 parent 98834ac commit 754b20e
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/QueryBuilder/QueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ public function from(string $fromExpression, ?string $alias = null, ...$args): s
{
$this->dirty();
$this->from = [$fromExpression, $alias];
$this->args['from'] = [];
$this->pushArgs('from', $args);
return $this;
}
Expand Down
25 changes: 25 additions & 0 deletions tests/cases/unit/QueryBuilderTest.from.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php declare(strict_types = 1);

/** @testCase */

namespace NextrasTests\Dbal;

require_once __DIR__ . '/../../bootstrap.php';


class QueryBuilderFromTest extends QueryBuilderTestCase
{
public function testRepeatedCall()
{
$this->assertBuilder(
['SELECT * FROM foo'],
$this->builder()
->from('%table', 'alias', 'tableName')
->from('foo')
);
}
}


$test = new QueryBuilderFromTest();
$test->run();

0 comments on commit 754b20e

Please sign in to comment.