-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added ability to use macroses on laravel builder, fixed wrong result …
…merging in selectAsync, added array join ability
- Loading branch information
Showing
6 changed files
with
134 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<?php | ||
|
||
namespace Tinderbox\ClickhouseBuilder\Query; | ||
|
||
use Tinderbox\ClickhouseBuilder\Query\Enums\JoinStrict; | ||
use Tinderbox\ClickhouseBuilder\Query\Enums\JoinType; | ||
|
||
class ArrayJoinClause | ||
{ | ||
/** | ||
* Identifier of array to join | ||
* | ||
* @var Expression|Identifier | ||
*/ | ||
private $arrayIdentifier; | ||
|
||
/** | ||
* Builder which initiated join. | ||
* | ||
* @var Builder | ||
*/ | ||
private $query; | ||
|
||
/** | ||
* JoinClause constructor. | ||
* | ||
* @param BaseBuilder $query | ||
*/ | ||
public function __construct(BaseBuilder $query) | ||
{ | ||
$this->query = $query; | ||
} | ||
|
||
/** | ||
* Set array identifier for join. | ||
* | ||
* @param string|Expression $arrayIdentifier | ||
* | ||
* @return ArrayJoinClause | ||
*/ | ||
public function array($arrayIdentifier): self | ||
{ | ||
if (is_string($arrayIdentifier)) { | ||
$arrayIdentifier = new Identifier($arrayIdentifier); | ||
} | ||
|
||
$this->arrayIdentifier = $arrayIdentifier; | ||
|
||
return $this; | ||
} | ||
|
||
/** | ||
* Get array identifier to join. | ||
* | ||
* @return Expression|Identifier | ||
*/ | ||
public function getArrayIdentifier() | ||
{ | ||
return $this->arrayIdentifier; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
|
||
namespace Tinderbox\ClickhouseBuilder\Query\Traits; | ||
|
||
use Tinderbox\ClickhouseBuilder\Query\ArrayJoinClause; | ||
use Tinderbox\ClickhouseBuilder\Query\BaseBuilder as Builder; | ||
|
||
trait ArrayJoinComponentCompiler | ||
{ | ||
/** | ||
* Compiles join to string to pass this string in query. | ||
* | ||
* @param Builder $query | ||
* @param ArrayJoinClause $join | ||
* | ||
* @return string | ||
*/ | ||
protected function compileArrayJoinComponent(Builder $query, ArrayJoinClause $join) : string | ||
{ | ||
$result = []; | ||
$result[] = 'ARRAY JOIN'; | ||
$result[] = $this->wrap($join->getArrayIdentifier()); | ||
|
||
return implode(' ', $result); | ||
} | ||
} |