Skip to content

Commit

Permalink
refactor(builder): refactor from zephir.
Browse files Browse the repository at this point in the history
  • Loading branch information
noone-silent committed Jul 31, 2024
1 parent 07c4526 commit e927847
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 47 deletions.
68 changes: 34 additions & 34 deletions src/Mvc/Model/Query/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -451,8 +451,8 @@ final public function autoescape(string $identifier): string
*/
public function betweenHaving(
string $expr,
string | float $minimum,
string | float $maximum,
string | float | int $minimum,
string | float | int $maximum,
string $operator = BuilderInterface::OPERATOR_AND
): BuilderInterface {
return $this->conditionBetween("Having", $operator, $expr, $minimum, $maximum);
Expand All @@ -465,18 +465,18 @@ public function betweenHaving(
* $builder->betweenWhere("price", 100.25, 200.50);
*```
*
* @param string $expr
* @param string|float $minimum
* @param string|float $maximum
* @param string $operator
* @param string $expr
* @param string|float|int $minimum
* @param string|float|int $maximum
* @param string $operator
*
* @throws Exception
* @return BuilderInterface
*/
public function betweenWhere(
string $expr,
string | float $minimum,
string | float $maximum,
string | float | int $minimum,
string | float | int $maximum,
string $operator = BuilderInterface::OPERATOR_AND
): BuilderInterface {
return $this->conditionBetween("Where", $operator, $expr, $minimum, $maximum);
Expand Down Expand Up @@ -1396,18 +1396,18 @@ public function limit(int $limit, ?int $offset = null): BuilderInterface
* $builder->notBetweenHaving("SUM(Robots.price)", 100.25, 200.50);
*```
*
* @param string $expr
* @param string|float $minimum
* @param string|float $maximum
* @param string $operator
* @param string $expr
* @param string|float|int $minimum
* @param string|float|int $maximum
* @param string $operator
*
* @throws Exception
* @return BuilderInterface
*/
public function notBetweenHaving(
string $expr,
string | float $minimum,
string | float $maximum,
string | float | int $minimum,
string | float | int $maximum,
string $operator = BuilderInterface::OPERATOR_AND
): BuilderInterface {
return $this->conditionNotBetween(
Expand All @@ -1426,18 +1426,18 @@ public function notBetweenHaving(
* $builder->notBetweenWhere("price", 100.25, 200.50);
*```
*
* @param string $expr
* @param string|float $minimum
* @param string|float $maximum
* @param string $operator
* @param string $expr
* @param string|float|int $minimum
* @param string|float|int $maximum
* @param string $operator
*
* @throws Exception
* @return BuilderInterface
*/
public function notBetweenWhere(
string $expr,
string | float $minimum,
string | float $maximum,
string | float | int $minimum,
string | float | int $maximum,
string $operator = BuilderInterface::OPERATOR_AND
): BuilderInterface {
return $this->conditionNotBetween(
Expand Down Expand Up @@ -1727,11 +1727,11 @@ public function where(
/**
* Appends a BETWEEN condition
*
* @param string $clause
* @param string $operator
* @param string $expr
* @param string|float $minimum
* @param string|float $maximum
* @param string $clause
* @param string $operator
* @param string $expr
* @param string|float|int $minimum
* @param string|float|int $maximum
*
* @throws Exception
* @return BuilderInterface
Expand All @@ -1740,8 +1740,8 @@ protected function conditionBetween(
string $clause,
string $operator,
string $expr,
string | float $minimum,
string | float $maximum
string | float | int $minimum,
string | float | int $maximum
): BuilderInterface {
if ($operator !== self::OPERATOR_AND && $operator !== self::OPERATOR_OR) {
throw new Exception(
Expand Down Expand Up @@ -1850,11 +1850,11 @@ protected function conditionIn(
/**
* Appends a NOT BETWEEN condition
*
* @param string $clause
* @param string $operator
* @param string $expr
* @param string|float $minimum
* @param string|float $maximum
* @param string $clause
* @param string $operator
* @param string $expr
* @param string|float|int $minimum
* @param string|float|int $maximum
*
* @throws Exception
* @return BuilderInterface
Expand All @@ -1863,8 +1863,8 @@ protected function conditionNotBetween(
string $clause,
string $operator,
string $expr,
string | float $minimum,
string | float $maximum
string | float | int $minimum,
string | float | int $maximum
): BuilderInterface {
if ($operator !== self::OPERATOR_AND && $operator !== self::OPERATOR_OR) {
throw new Exception(
Expand Down
24 changes: 12 additions & 12 deletions src/Mvc/Model/Query/BuilderInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,17 @@ public function andWhere(
/**
* Appends a BETWEEN condition to the current conditions
*
* @param string $expr
* @param string|float $minimum
* @param string|float $maximum
* @param string $operator
* @param string $expr
* @param string|float|int $minimum
* @param string|float|int $maximum
* @param string $operator
*
* @return BuilderInterface
*/
public function betweenWhere(
string $expr,
string | float $minimum,
string | float $maximum,
string | float | int $minimum,
string | float | int $maximum,
string $operator = BuilderInterface::OPERATOR_AND
): BuilderInterface;

Expand Down Expand Up @@ -356,17 +356,17 @@ public function limit(int $limit, ?int $offset = null): BuilderInterface;
/**
* Appends a NOT BETWEEN condition to the current conditions
*
* @param string $expr
* @param string|float $minimum
* @param string|float $maximum
* @param string $operator
* @param string $expr
* @param string|float|int $minimum
* @param string|float|int $maximum
* @param string $operator
*
* @return BuilderInterface
*/
public function notBetweenWhere(
string $expr,
string | float $minimum,
string | float $maximum,
string | float | int $minimum,
string | float | int $maximum,
string $operator = BuilderInterface::OPERATOR_AND
): BuilderInterface;

Expand Down
5 changes: 4 additions & 1 deletion src/Paginator/Adapter/QueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,10 @@ public function __construct(array $config)
}
$builder = $config['builder'];

if (isset($config["columns"])) {
if (
isset($config["columns"]) &&
(is_array($config['columns']) || is_string($config['columns']))
) {
$this->columns = $config["columns"];
}

Expand Down
2 changes: 2 additions & 0 deletions tests/database/Mvc/Model/Criteria/JoinCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
namespace Phalcon\Tests\Database\Mvc\Model\Criteria;

use Codeception\Attribute\Group;
use Codeception\Attribute\Skip;
use DatabaseTester;
use Phalcon\Mvc\Model\Criteria;
use Phalcon\Mvc\Model\Query\Builder;
Expand Down Expand Up @@ -91,6 +92,7 @@ public function mvcModelCriteriaJoin(DatabaseTester $I)
* @group pgsql
*/
#[Group('pgsql')]
#[Skip('This currently does not work')]
public function mvcModelCriteriaJoinManyToManyMultipleSchema(DatabaseTester $I)
{
$I->wantToTest('Mvc\Model\Criteria - join() and use ManyToMany with Multiple schemas');
Expand Down

0 comments on commit e927847

Please sign in to comment.