Skip to content

Commit

Permalink
Fix joins readme & new test case (#37)
Browse files Browse the repository at this point in the history
  • Loading branch information
vitalcrazz authored Jan 17, 2021
1 parent 5441f01 commit 8da8546
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,8 @@ SELECT * FROM `table` GLOBAL ANY LEFT JOIN `another_table` AS `alias` USING `col
For performing subquery as first argument you can pass closure or builder.

```php
$builder->from('table')->join(function ($query) {
$query->select('column1', 'column2')->from('table2');
$builder->from('table')->join(function ($join) {
$join->query()->select('column1', 'column2')->from('table2');
}, 'any', 'left', ['column1', 'column2']);
$builder->from('table')->join($builder->select('column1', 'column2')->from('table2'), 'any', 'left', ['column1', 'column2']);
Expand Down
5 changes: 5 additions & 0 deletions tests/BuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,11 @@ public function test_join_with_closure()

$builder = $this->getBuilder()->anyLeftJoin($this->getBuilder()->from('table'), ['column']);
$this->assertEquals('SELECT * ANY LEFT JOIN (SELECT * FROM `table`) USING `column`', $builder->toSql());

$builder->from('table')->join(function ($join) {
$join->query()->select('column1', 'column2')->from('table2');
}, 'any', 'left', ['column1', 'column2']);
$this->assertEquals('SELECT * FROM `table` ANY LEFT JOIN (SELECT `column1`, `column2` FROM `table2`) USING `column1`, `column2`', $builder->toSql());
}

public function test_preWheres()
Expand Down

0 comments on commit 8da8546

Please sign in to comment.