diff --git a/src/QueryBuilder/QueryBuilder.php b/src/QueryBuilder/QueryBuilder.php index a124ebf5..2e0dd185 100644 --- a/src/QueryBuilder/QueryBuilder.php +++ b/src/QueryBuilder/QueryBuilder.php @@ -294,7 +294,7 @@ public function removeJoins(): self private function join(string $type, string $toExpression, string $onExpression, array $args): self { $this->dirty(); - $this->join[$toExpression] = [ + $this->join[] = [ 'type' => $type, 'table' => $toExpression, 'on' => $onExpression, diff --git a/tests/cases/unit/QueryBuilderTest.joins.phpt b/tests/cases/unit/QueryBuilderTest.joins.phpt index c0d078c1..edb8e2d0 100644 --- a/tests/cases/unit/QueryBuilderTest.joins.phpt +++ b/tests/cases/unit/QueryBuilderTest.joins.phpt @@ -15,13 +15,21 @@ class QueryBuilderJoinsTest extends QueryBuilderTestCase [ 'SELECT * FROM one AS [o] ' . 'LEFT JOIN two AS [t] ON (o.userId = t.userId) ' . + 'LEFT JOIN %table ON (%table.id = tbl.t1_id) ' . + 'LEFT JOIN %table ON (%table.id = tbl.t2_id) ' . 'INNER JOIN three AS [th] ON (t.userId = th.userId) ' . - 'RIGHT JOIN four AS [f] ON (th.userId = f.userId)' + 'RIGHT JOIN four AS [f] ON (th.userId = f.userId)', + 't1', + 't1', + 't2', + 't2' ], $this->builder() ->from('one', 'o') ->select('*') ->joinLeft('two AS [t]', 'o.userId = t.userId') + ->joinLeft('%table', '%table.id = tbl.t1_id', 't1', 't1') + ->joinLeft('%table', '%table.id = tbl.t2_id', 't2', 't2') ->joinInner('three AS [th]', 't.userId = th.userId') ->joinRight('four AS [f]', 'th.userId = f.userId') );