-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Add some documents manipulation operators * Row must be nullable to operate on all the document * WIP HasFields * Remove unused property * WIP Tests * Move GetFieldLogic to Query/Manipulation namespace * Fix hasFields implementation for Table and Row * Fix keys implementation manipulation * Fix pluck implementation manipulation * Fix values implementation manipulation * Fix without implementation manipulation * Remove obsolete nullable type, since if not passed it defaults to null
- Loading branch information
Showing
27 changed files
with
625 additions
and
28 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 was deleted.
Oops, something went wrong.
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 | ||
declare(strict_types = 1); | ||
|
||
namespace TBolier\RethinkQL\Query\Manipulation; | ||
|
||
use TBolier\RethinkQL\Query\AbstractQuery; | ||
use TBolier\RethinkQL\Query\Aggregation\AggregationTrait; | ||
use TBolier\RethinkQL\Query\Operation\OperationTrait; | ||
use TBolier\RethinkQL\Query\QueryInterface; | ||
use TBolier\RethinkQL\Query\Transformation\TransformationTrait; | ||
use TBolier\RethinkQL\RethinkInterface; | ||
use TBolier\RethinkQL\Types\Term\TermType; | ||
|
||
class HasFields extends AbstractQuery | ||
{ | ||
use AggregationTrait; | ||
use OperationTrait; | ||
use TransformationTrait; | ||
|
||
/** | ||
* @var array | ||
*/ | ||
private $keys; | ||
|
||
/** | ||
* @var QueryInterface | ||
*/ | ||
private $query; | ||
|
||
public function __construct( | ||
RethinkInterface $rethink, | ||
QueryInterface $query, | ||
array $keys | ||
) { | ||
parent::__construct($rethink); | ||
|
||
$this->rethink = $rethink; | ||
$this->query = $query; | ||
$this->keys = $keys; | ||
} | ||
|
||
public function toArray(): array | ||
{ | ||
if (\count($this->keys) === 1) { | ||
$keysQuery = implode($this->keys); | ||
} else { | ||
$keysQuery = [ | ||
TermType::MAKE_ARRAY, | ||
array_values($this->keys) | ||
]; | ||
} | ||
|
||
return [ | ||
TermType::HAS_FIELDS, | ||
[ | ||
$this->query->toArray(), | ||
$keysQuery | ||
] | ||
]; | ||
} | ||
} |
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,43 @@ | ||
<?php | ||
declare(strict_types = 1); | ||
|
||
namespace TBolier\RethinkQL\Query\Manipulation; | ||
|
||
use TBolier\RethinkQL\Query\AbstractQuery; | ||
use TBolier\RethinkQL\Query\Aggregation\AggregationTrait; | ||
use TBolier\RethinkQL\Query\Operation\OperationTrait; | ||
use TBolier\RethinkQL\Query\QueryInterface; | ||
use TBolier\RethinkQL\Query\Transformation\TransformationTrait; | ||
use TBolier\RethinkQL\RethinkInterface; | ||
use TBolier\RethinkQL\Types\Term\TermType; | ||
|
||
class Keys extends AbstractQuery | ||
{ | ||
use AggregationTrait; | ||
use TransformationTrait; | ||
|
||
/** | ||
* @var QueryInterface | ||
*/ | ||
private $query; | ||
|
||
public function __construct( | ||
RethinkInterface $rethink, | ||
QueryInterface $query | ||
) { | ||
parent::__construct($rethink); | ||
|
||
$this->query = $query; | ||
$this->rethink = $rethink; | ||
} | ||
|
||
public function toArray(): array | ||
{ | ||
return [ | ||
TermType::KEYS, | ||
[ | ||
$this->query->toArray() | ||
] | ||
]; | ||
} | ||
} |
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,12 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace TBolier\RethinkQL\Query\Manipulation; | ||
|
||
trait LogicTrait | ||
{ | ||
public function getField(string $field): GetField | ||
{ | ||
return new GetField($this->rethink, $field, $this->query); | ||
} | ||
} |
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,29 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace TBolier\RethinkQL\Query\Manipulation; | ||
|
||
use TBolier\RethinkQL\Query\QueryInterface; | ||
|
||
trait ManipulationTrait | ||
{ | ||
public function pluck(...$keys): Pluck | ||
{ | ||
return new Pluck($this->rethink, /** @scrutinizer ignore-type */ $this, $keys); | ||
} | ||
|
||
public function without(...$keys): Without | ||
{ | ||
return new Without($this->rethink, /** @scrutinizer ignore-type */ $this, $keys); | ||
} | ||
|
||
public function keys(): Keys | ||
{ | ||
return new Keys($this->rethink, /** @scrutinizer ignore-type */ $this); | ||
} | ||
|
||
public function values(): Values | ||
{ | ||
return new Values($this->rethink, /** @scrutinizer ignore-type */ $this); | ||
} | ||
} |
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 | ||
declare(strict_types = 1); | ||
|
||
namespace TBolier\RethinkQL\Query\Manipulation; | ||
|
||
use TBolier\RethinkQL\Query\AbstractQuery; | ||
use TBolier\RethinkQL\Query\Aggregation\AggregationTrait; | ||
use TBolier\RethinkQL\Query\Operation\OperationTrait; | ||
use TBolier\RethinkQL\Query\QueryInterface; | ||
use TBolier\RethinkQL\Query\Transformation\TransformationTrait; | ||
use TBolier\RethinkQL\RethinkInterface; | ||
use TBolier\RethinkQL\Types\Term\TermType; | ||
|
||
class Pluck extends AbstractQuery | ||
{ | ||
use AggregationTrait; | ||
use OperationTrait; | ||
use TransformationTrait; | ||
|
||
/** | ||
* @var array | ||
*/ | ||
private $keys; | ||
|
||
/** | ||
* @var QueryInterface | ||
*/ | ||
private $query; | ||
|
||
public function __construct( | ||
RethinkInterface $rethink, | ||
QueryInterface $query, | ||
array $keys | ||
) { | ||
parent::__construct($rethink); | ||
|
||
$this->query = $query; | ||
$this->rethink = $rethink; | ||
$this->keys = $keys; | ||
} | ||
|
||
public function toArray(): array | ||
{ | ||
if (\count($this->keys) === 1) { | ||
$keysQuery = implode($this->keys); | ||
} else { | ||
$keysQuery = [ | ||
TermType::MAKE_ARRAY, | ||
array_values($this->keys) | ||
]; | ||
} | ||
|
||
return [ | ||
TermType::PLUCK, | ||
[ | ||
$this->query->toArray(), | ||
$keysQuery | ||
] | ||
]; | ||
} | ||
} |
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,52 @@ | ||
<?php | ||
declare(strict_types = 1); | ||
|
||
namespace TBolier\RethinkQL\Query\Manipulation; | ||
|
||
use TBolier\RethinkQL\Query\AbstractQuery; | ||
use TBolier\RethinkQL\Query\Aggregation\AggregationTrait; | ||
use TBolier\RethinkQL\Query\Operation\OperationTrait; | ||
use TBolier\RethinkQL\Query\QueryInterface; | ||
use TBolier\RethinkQL\Query\Transformation\TransformationTrait; | ||
use TBolier\RethinkQL\RethinkInterface; | ||
use TBolier\RethinkQL\Types\Term\TermType; | ||
|
||
class RowHasFields extends AbstractQuery | ||
{ | ||
/** | ||
* @var array | ||
*/ | ||
private $keys; | ||
|
||
public function __construct( | ||
RethinkInterface $rethink, | ||
array $keys | ||
) { | ||
parent::__construct($rethink); | ||
|
||
$this->keys = $keys; | ||
$this->rethink = $rethink; | ||
} | ||
|
||
public function toArray(): array | ||
{ | ||
if (\count($this->keys) === 1) { | ||
$keysQuery = implode($this->keys); | ||
} else { | ||
$keysQuery = [ | ||
TermType::MAKE_ARRAY, | ||
array_values($this->keys) | ||
]; | ||
} | ||
|
||
return [ | ||
TermType::HAS_FIELDS, | ||
[ | ||
[ | ||
TermType::IMPLICIT_VAR | ||
], | ||
$keysQuery | ||
] | ||
]; | ||
} | ||
} |
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,49 @@ | ||
<?php | ||
declare(strict_types = 1); | ||
|
||
namespace TBolier\RethinkQL\Query\Manipulation; | ||
|
||
use TBolier\RethinkQL\Query\AbstractQuery; | ||
use TBolier\RethinkQL\Query\Aggregation\AggregationTrait; | ||
use TBolier\RethinkQL\Query\Operation\OperationTrait; | ||
use TBolier\RethinkQL\Query\QueryInterface; | ||
use TBolier\RethinkQL\Query\Transformation\TransformationTrait; | ||
use TBolier\RethinkQL\RethinkInterface; | ||
use TBolier\RethinkQL\Types\Term\TermType; | ||
|
||
class Values extends AbstractQuery | ||
{ | ||
use AggregationTrait; | ||
use OperationTrait; | ||
use TransformationTrait; | ||
|
||
/** | ||
* @var array | ||
*/ | ||
private $keys; | ||
|
||
/** | ||
* @var QueryInterface | ||
*/ | ||
private $query; | ||
|
||
public function __construct( | ||
RethinkInterface $rethink, | ||
QueryInterface $query | ||
) { | ||
parent::__construct($rethink); | ||
|
||
$this->query = $query; | ||
$this->rethink = $rethink; | ||
} | ||
|
||
public function toArray(): array | ||
{ | ||
return [ | ||
TermType::VALUES, | ||
[ | ||
$this->query->toArray() | ||
], | ||
]; | ||
} | ||
} |
Oops, something went wrong.