Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/Query/Traits/HavingTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,18 +86,18 @@ public function orHaving(...$args): self
/**
* Convert various amount of where function arguments into valid where token.
*
* @param string $boolean Boolean joiner (AND | OR).
* @param string $boolean Boolean joiner (AND | OR).
* @param array $params Set of parameters collected from where functions.
* @param array $tokens Array to aggregate compiled tokens. Reference.
* @param array $tokens Array to aggregate compiled tokens. Reference.
* @param callable $wrapper Callback or closure used to wrap/collect every potential
* parameter.
*
* @throws BuilderException
*/
abstract protected function registerToken(
$boolean,
string $boolean,
array $params,
&$tokens,
array &$tokens,
callable $wrapper
);

Expand Down
10 changes: 5 additions & 5 deletions src/Query/Traits/JoinTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public function join($type, $outer, string $alias = null, $on = null): self
'on' => []
];

return call_user_func_array([$this, 'on'], array_slice(func_get_args(), 2));
return $on === null ? $this : $this->on(...$on);
}

/**
Expand Down Expand Up @@ -333,18 +333,18 @@ public function orOnWhere(...$args): self
/**
* Convert various amount of where function arguments into valid where token.
*
* @param string $boolean Boolean joiner (AND | OR).
* @param string $boolean Boolean joiner (AND | OR).
* @param array $params Set of parameters collected from where functions.
* @param array $tokens Array to aggregate compiled tokens. Reference.
* @param array $tokens Array to aggregate compiled tokens. Reference.
* @param callable $wrapper Callback or closure used to wrap/collect every potential
* parameter.
*
* @throws BuilderException
*/
abstract protected function registerToken(
$boolean,
string $boolean,
array $params,
&$tokens,
array &$tokens,
callable $wrapper
);

Expand Down
6 changes: 3 additions & 3 deletions src/Query/Traits/TokenTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ trait TokenTrait
/**
* Convert various amount of where function arguments into valid where token.
*
* @param string $boolean Boolean joiner (AND | OR).
* @param string $boolean Boolean joiner (AND | OR).
* @param array $params Set of parameters collected from where functions.
* @param array $tokens Array to aggregate compiled tokens. Reference.
* @param array $tokens Array to aggregate compiled tokens. Reference.
* @param callable $wrapper Callback or closure used to wrap/collect every potential
* parameter.
*
* @throws BuilderException
*/
protected function registerToken($boolean, array $params, &$tokens, callable $wrapper): void
protected function registerToken(string $boolean, array $params, array &$tokens, callable $wrapper): void
{
$count = count($params);
if ($count === 0) {
Expand Down
9 changes: 5 additions & 4 deletions src/Query/Traits/WhereTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,17 +85,18 @@ public function orWhere(...$args): self
/**
* Convert various amount of where function arguments into valid where token.
*
* @param string $boolean Boolean joiner (AND | OR).
* @param string $boolean Boolean joiner (AND | OR).
* @param array $params Set of parameters collected from where functions.
* @param array $tokens Array to aggregate compiled tokens. Reference.
* @param array $tokens Array to aggregate compiled tokens. Reference.
* @param callable $wrapper Callback or closure used to wrap/collect every potential
* parameter.
*
* @throws BuilderException
*/
abstract protected function registerToken(
$boolean,
string $boolean,
array $params,
&$tokens,
array &$tokens,
callable $wrapper
);

Expand Down
37 changes: 37 additions & 0 deletions tests/Database/SelectQueryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2042,6 +2042,43 @@ public function testLeftJoin3(): void
);
}

public function testLeftJoin4(): void
{
$select = $this->database->select()
->from(['users'])
->join('LEFT', 'photos', 'pht', ['pht.user_id', 'users.id']);

$this->assertSameQuery(
'SELECT * FROM {users} LEFT JOIN {photos} AS {pht} ON {pht}.{user_id} = {users}.{id}',
$select
);
}

// Todo: make this case valid
// public function testLeftJoin5(): void
// {
// $select = $this->database->select()
// ->from(['users'])
// ->join('LEFT', 'photos', 'pht', ['@AND' => ['pht.user_id' => 'users.id']]);
//
// $this->assertSameQuery(
// 'SELECT * FROM {users} LEFT JOIN {photos} AS {pht} ON {pht}.{user_id} = {users}.{id}',
// $select
// );
// }

public function testLeftJoin6(): void
{
$select = $this->database->select()
->from(['users'])
->join('LEFT', 'photos', 'pht', [['pht.user_id' => 'users.id']]);

$this->assertSameQuery(
'SELECT * FROM {users} LEFT JOIN {photos} AS {pht} ON {pht}.{user_id} = {users}.{id}',
$select
);
}

public function testRightJoin0(): void
{
$select = $this->database->select()
Expand Down