diff --git a/application/Espo/ORM/Query/Part/SelectExpression.php b/application/Espo/ORM/Query/Part/SelectExpression.php index 53ca8958f0..3359469225 100644 --- a/application/Espo/ORM/Query/Part/SelectExpression.php +++ b/application/Espo/ORM/Query/Part/SelectExpression.php @@ -29,7 +29,7 @@ namespace Espo\ORM\Query\Part; -class SelectExpression implements SelectItem +class SelectExpression { private $expression; diff --git a/application/Espo/ORM/Query/Part/SelectItem.php b/application/Espo/ORM/Query/Part/SelectItem.php deleted file mode 100644 index 8e07af9686..0000000000 --- a/application/Espo/ORM/Query/Part/SelectItem.php +++ /dev/null @@ -1,37 +0,0 @@ -params['orderBy'] ?? []; } + /** + * Get WHERE clause. + */ public function getWhere(): ?WhereClause { $whereClause = $this->params['whereClause'] ?? null; diff --git a/application/Espo/ORM/Query/SelectBuilder.php b/application/Espo/ORM/Query/SelectBuilder.php index 86448a790a..1cd697bb9f 100644 --- a/application/Espo/ORM/Query/SelectBuilder.php +++ b/application/Espo/ORM/Query/SelectBuilder.php @@ -30,7 +30,7 @@ namespace Espo\ORM\Query; use Espo\ORM\Query\Part\Expression; -use Espo\ORM\Query\Part\SelectItem; +use Espo\ORM\Query\Part\SelectExpression; use InvalidArgumentException; use RuntimeException; @@ -127,23 +127,21 @@ class SelectBuilder implements Builder /** * Specify SELECT. Columns and expressions to be selected. If not called, then * all entity attributes will be selected. Passing an array will reset - * previously set items. Passing a string|Expression|SelectItem will append the item. + * previously set items. Passing a SelectExpression|Expression|string will append the item. * * Usage options: + * * `select(SelectExpression $expression)` * * `select([$expr1, $expr2, ...])` - * * `select([[$expr1, $alias1], [$expr2, $alias2], ...])` - * * `select([$selectItem1, $selectItem2, ...])` - * * `select(string|Expression $expression)` - * * `select(string|Expression $expression, string $alias)` - * * `select(SelectItem $selectItem)` + * * `select(string $expression, string $alias)` * - * @param array|string|Expression|SelectItem $select An array of expressions or one expression. - * @param string|null $alias An alias. Actual if the first parameter is a string. + * @param SelectExpression|SelectExpression[]|Expression|string $select + * An array of expressions or one expression. + * @param string|null $alias An alias. Actual if the first parameter is not an array. */ public function select($select, ?string $alias = null): self { if (is_array($select)) { - $this->params['select'] = $this->normilizeSelectItemArray($select); + $this->params['select'] = $this->normilizeSelectExpressionArray($select); return $this; } @@ -151,7 +149,7 @@ class SelectBuilder implements Builder if ($select instanceof Expression) { $select = $select->getValue(); } - else if ($select instanceof SelectItem) { + else if ($select instanceof SelectExpression) { $alias = $alias ?? $select->getAlias(); $select = $select->getExpression()->getValue(); } @@ -271,7 +269,7 @@ class SelectBuilder implements Builder return $this; } - private function normilizeSelectItemArray(array $itemList): array + private function normilizeSelectExpressionArray(array $itemList): array { $resultList = []; @@ -282,7 +280,7 @@ class SelectBuilder implements Builder continue; } - if ($item instanceof SelectItem) { + if ($item instanceof SelectExpression) { $resultList[] = $item->getAlias() ? [$item->getExpression()->getValue(), $item->getAlias()] : [$item->getExpression()->getValue()]; diff --git a/application/Espo/ORM/QueryBuilder.php b/application/Espo/ORM/QueryBuilder.php index 7b5916f969..5876a3f6b5 100644 --- a/application/Espo/ORM/QueryBuilder.php +++ b/application/Espo/ORM/QueryBuilder.php @@ -38,7 +38,7 @@ use Espo\ORM\{ Query\Query, Query\Builder, Query\Part\Expression, - Query\Part\SelectItem, + Query\Part\SelectExpression, }; use ReflectionClass; @@ -52,18 +52,16 @@ class QueryBuilder /** * Specify SELECT. Columns and expressions to be selected. If not called, then * all entity attributes will be selected. Passing an array will reset - * previously set items. Passing a string|Expression|SelectItem will append the item. + * previously set items. Passing a SelectExpression|Expression|string will append the item. * * Usage options: + * * `select(SelectExpression $expression)` * * `select([$expr1, $expr2, ...])` - * * `select([[$expr1, $alias1], [$expr2, $alias2], ...])` - * * `select([$selectItem1, $selectItem2, ...])` - * * `select(string|Expression $expression)` - * * `select(string|Expression $expression, string $alias)` - * * `select(SelectItem $selectItem)` + * * `select(string $expression, string $alias)` * - * @param array|string|Expression|SelectItem $select An array of expressions or one expression. - * @param string|null $alias An alias. Actual if the first parameter is a string. + * @param SelectExpression|SelectExpression[]|Expression|string $select + * An array of expressions or one expression. + * @param string|null $alias An alias. Actual if the first parameter is not an array. */ public function select($select = null, ?string $alias = null): SelectBuilder { diff --git a/application/Espo/ORM/Repository/RDBRelation.php b/application/Espo/ORM/Repository/RDBRelation.php index 904b6c9e4d..30b0690456 100644 --- a/application/Espo/ORM/Repository/RDBRelation.php +++ b/application/Espo/ORM/Repository/RDBRelation.php @@ -35,7 +35,7 @@ use Espo\ORM\{ EntityManager, Query\Select, Query\Part\WhereItem, - Query\Part\SelectItem, + Query\Part\SelectExpression, Mapper\RDBMapper, Repository\RDBRelationSelectBuilder as Builder, }; @@ -286,18 +286,16 @@ class RDBRelation /** * Specify SELECT. Columns and expressions to be selected. If not called, then * all entity attributes will be selected. Passing an array will reset - * previously set items. Passing a string|Expression|SelectItem will append the item. + * previously set items. Passing a SelectExpression|Expression|string will append the item. * * Usage options: + * * `select(SelectExpression $expression)` * * `select([$expr1, $expr2, ...])` - * * `select([[$expr1, $alias1], [$expr2, $alias2], ...])` - * * `select([$selectItem1, $selectItem2, ...])` - * * `select(string|Expression $expression)` - * * `select(string|Expression $expression, string $alias)` - * * `select(SelectItem $selectItem)` + * * `select(string $expression, string $alias)` * - * @param array|string|Expression|SelectItem $select An array of expressions or one expression. - * @param string|null $alias An alias. Actual if the first parameter is a string. + * @param SelectExpression|SelectExpression[]|Expression|string $select + * An array of expressions or one expression. + * @param string|null $alias An alias. Actual if the first parameter is not an array. */ public function select($select = [], ?string $alias = null): Builder { diff --git a/application/Espo/ORM/Repository/RDBRelationSelectBuilder.php b/application/Espo/ORM/Repository/RDBRelationSelectBuilder.php index f14f96973c..7fc9d18938 100644 --- a/application/Espo/ORM/Repository/RDBRelationSelectBuilder.php +++ b/application/Espo/ORM/Repository/RDBRelationSelectBuilder.php @@ -37,7 +37,7 @@ use Espo\ORM\{ Query\Select, Query\SelectBuilder, Query\Part\WhereItem, - Query\Part\SelectItem, + Query\Part\SelectExpression, Mapper\Mapper, }; @@ -364,18 +364,16 @@ class RDBRelationSelectBuilder /** * Specify SELECT. Columns and expressions to be selected. If not called, then * all entity attributes will be selected. Passing an array will reset - * previously set items. Passing a string|Expression|SelectItem will append the item. + * previously set items. Passing a SelectExpression|Expression|string will append the item. * * Usage options: + * * `select(SelectExpression $expression)` * * `select([$expr1, $expr2, ...])` - * * `select([[$expr1, $alias1], [$expr2, $alias2], ...])` - * * `select([$selectItem1, $selectItem2, ...])` - * * `select(string|Expression $expression)` - * * `select(string|Expression $expression, string $alias)` - * * `select(SelectItem $selectItem)` + * * `select(string $expression, string $alias)` * - * @param array|string|Expression|SelectItem $select An array of expressions or one expression. - * @param string|null $alias An alias. Actual if the first parameter is a string. + * @param SelectExpression|SelectExpression[]|Expression|string $select + * An array of expressions or one expression. + * @param string|null $alias An alias. Actual if the first parameter is not an array. */ public function select($select, ?string $alias = null): self { diff --git a/application/Espo/ORM/Repository/RDBRepository.php b/application/Espo/ORM/Repository/RDBRepository.php index 48e76bdc19..7aa402cc66 100644 --- a/application/Espo/ORM/Repository/RDBRepository.php +++ b/application/Espo/ORM/Repository/RDBRepository.php @@ -38,7 +38,7 @@ use Espo\ORM\{ Mapper\RDBMapper, Query\Select, Query\Part\WhereItem, - Query\Part\SelectItem, + Query\Part\SelectExpression, }; use StdClass; @@ -782,18 +782,16 @@ class RDBRepository extends Repository /** * Specify SELECT. Columns and expressions to be selected. If not called, then * all entity attributes will be selected. Passing an array will reset - * previously set items. Passing a string|Expression|SelectItem will append the item. + * previously set items. Passing a SelectExpression|Expression|string will append the item. * * Usage options: + * * `select(SelectExpression $expression)` * * `select([$expr1, $expr2, ...])` - * * `select([[$expr1, $alias1], [$expr2, $alias2], ...])` - * * `select([$selectItem1, $selectItem2, ...])` - * * `select(string|Expression $expression)` - * * `select(string|Expression $expression, string $alias)` - * * `select(SelectItem $selectItem)` + * * `select(string $expression, string $alias)` * - * @param array|string|Expression|SelectItem $select An array of expressions or one expression. - * @param string|null $alias An alias. Actual if the first parameter is a string. + * @param SelectExpression|SelectExpression[]|Expression|string $select + * An array of expressions or one expression. + * @param string|null $alias An alias. Actual if the first parameter is not an array. */ public function select($select = [], ?string $alias = null): RDBSelectBuilder { diff --git a/application/Espo/ORM/Repository/RDBSelectBuilder.php b/application/Espo/ORM/Repository/RDBSelectBuilder.php index 6c110fb7cf..22edf18b4f 100644 --- a/application/Espo/ORM/Repository/RDBSelectBuilder.php +++ b/application/Espo/ORM/Repository/RDBSelectBuilder.php @@ -37,7 +37,7 @@ use Espo\ORM\{ Query\Select, Query\SelectBuilder, Query\Part\WhereItem, - Query\Part\SelectItem, + Query\Part\SelectExpression, Mapper\Mapper, }; @@ -304,7 +304,7 @@ class RDBSelectBuilder /** * Specify SELECT. Columns and expressions to be selected. If not called, then * all entity attributes will be selected. Passing an array will reset - * previously set items. Passing a string|Expression|SelectItem will append the item. + * previously set items. Passing a string|Expression|SelectExpression will append the item. * * Usage options: * * `select([$expr1, $expr2, ...])` @@ -312,9 +312,9 @@ class RDBSelectBuilder * * `select([$selectItem1, $selectItem2, ...])` * * `select(string|Expression $expression)` * * `select(string|Expression $expression, string $alias)` - * * `select(SelectItem $selectItem)` + * * `select(SelectExpression $selectItem)` * - * @param array|string|Expression|SelectItem $select An array of expressions or one expression. + * @param array|string|Expression|SelectExpression $select An array of expressions or one expression. * @param string|null $alias An alias. Actual if the first parameter is a string. */ public function select($select, ?string $alias = null): self