rename
This commit is contained in:
+1
-1
@@ -29,7 +29,7 @@
|
||||
|
||||
namespace Espo\ORM\Query\Part;
|
||||
|
||||
class SelectExpression
|
||||
class Selection
|
||||
{
|
||||
private $expression;
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
namespace Espo\ORM\Query;
|
||||
|
||||
use Espo\ORM\Query\Part\WhereClause;
|
||||
use Espo\ORM\Query\Part\SelectExpression;
|
||||
use Espo\ORM\Query\Part\Selection;
|
||||
use Espo\ORM\Query\Part\OrderExpression;
|
||||
use Espo\ORM\Query\Part\Expression;
|
||||
|
||||
@@ -103,19 +103,19 @@ class Select implements SelectingQuery
|
||||
/**
|
||||
* Get SELECT items.
|
||||
*
|
||||
* @return SelectExpression[]
|
||||
* @return Selection[]
|
||||
*/
|
||||
public function getSelect(): array
|
||||
{
|
||||
return array_map(
|
||||
function ($item) {
|
||||
if (is_array($item) && count($item)) {
|
||||
return SelectExpression::fromString($item[0])
|
||||
return Selection::fromString($item[0])
|
||||
->withAlias($item[1] ?? null);
|
||||
}
|
||||
|
||||
if (is_string($item)) {
|
||||
return SelectExpression::fromString($item);
|
||||
return Selection::fromString($item);
|
||||
}
|
||||
|
||||
throw new RuntimeException("Bad select item.");
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
namespace Espo\ORM\Query;
|
||||
|
||||
use Espo\ORM\Query\Part\Expression;
|
||||
use Espo\ORM\Query\Part\SelectExpression;
|
||||
use Espo\ORM\Query\Part\Selection;
|
||||
|
||||
use InvalidArgumentException;
|
||||
use RuntimeException;
|
||||
@@ -134,7 +134,7 @@ class SelectBuilder implements Builder
|
||||
* * `select([$expr1, $expr2, ...])`
|
||||
* * `select(string $expression, string $alias)`
|
||||
*
|
||||
* @param SelectExpression|SelectExpression[]|Expression|string $select
|
||||
* @param Selection|Selection[]|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.
|
||||
*/
|
||||
@@ -149,7 +149,7 @@ class SelectBuilder implements Builder
|
||||
if ($select instanceof Expression) {
|
||||
$select = $select->getValue();
|
||||
}
|
||||
else if ($select instanceof SelectExpression) {
|
||||
else if ($select instanceof Selection) {
|
||||
$alias = $alias ?? $select->getAlias();
|
||||
$select = $select->getExpression()->getValue();
|
||||
}
|
||||
@@ -288,7 +288,7 @@ class SelectBuilder implements Builder
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($item instanceof SelectExpression) {
|
||||
if ($item instanceof Selection) {
|
||||
$resultList[] = $item->getAlias() ?
|
||||
[$item->getExpression()->getValue(), $item->getAlias()] :
|
||||
[$item->getExpression()->getValue()];
|
||||
|
||||
@@ -38,7 +38,7 @@ use Espo\ORM\{
|
||||
Query\Query,
|
||||
Query\Builder,
|
||||
Query\Part\Expression,
|
||||
Query\Part\SelectExpression,
|
||||
Query\Part\Selection,
|
||||
};
|
||||
|
||||
use ReflectionClass;
|
||||
@@ -59,7 +59,7 @@ class QueryBuilder
|
||||
* * `select([$expr1, $expr2, ...])`
|
||||
* * `select(string $expression, string $alias)`
|
||||
*
|
||||
* @param SelectExpression|SelectExpression[]|Expression|string $select
|
||||
* @param Selection|Selection[]|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.
|
||||
*/
|
||||
|
||||
@@ -35,7 +35,7 @@ use Espo\ORM\{
|
||||
EntityManager,
|
||||
Query\Select,
|
||||
Query\Part\WhereItem,
|
||||
Query\Part\SelectExpression,
|
||||
Query\Part\Selection,
|
||||
Query\Part\Join,
|
||||
Mapper\RDBMapper,
|
||||
Repository\RDBRelationSelectBuilder as Builder,
|
||||
@@ -294,7 +294,7 @@ class RDBRelation
|
||||
* * `select([$expr1, $expr2, ...])`
|
||||
* * `select(string $expression, string $alias)`
|
||||
*
|
||||
* @param SelectExpression|SelectExpression[]|Expression|string $select
|
||||
* @param Selection|Selection[]|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.
|
||||
*/
|
||||
|
||||
@@ -37,7 +37,7 @@ use Espo\ORM\{
|
||||
Query\Select,
|
||||
Query\SelectBuilder,
|
||||
Query\Part\WhereItem,
|
||||
Query\Part\SelectExpression,
|
||||
Query\Part\Selection,
|
||||
Query\Part\Join,
|
||||
Mapper\Mapper,
|
||||
};
|
||||
@@ -375,7 +375,7 @@ class RDBRelationSelectBuilder
|
||||
* * `select([$expr1, $expr2, ...])`
|
||||
* * `select(string $expression, string $alias)`
|
||||
*
|
||||
* @param SelectExpression|SelectExpression[]|Expression|string $select
|
||||
* @param Selection|Selection[]|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.
|
||||
*/
|
||||
|
||||
@@ -38,7 +38,7 @@ use Espo\ORM\{
|
||||
Mapper\RDBMapper,
|
||||
Query\Select,
|
||||
Query\Part\WhereItem,
|
||||
Query\Part\SelectExpression,
|
||||
Query\Part\Selection,
|
||||
Query\Part\Join,
|
||||
};
|
||||
|
||||
@@ -790,7 +790,7 @@ class RDBRepository extends Repository
|
||||
* * `select([$expr1, $expr2, ...])`
|
||||
* * `select(string $expression, string $alias)`
|
||||
*
|
||||
* @param SelectExpression|SelectExpression[]|Expression|string $select
|
||||
* @param Selection|Selection[]|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.
|
||||
*/
|
||||
|
||||
@@ -37,7 +37,7 @@ use Espo\ORM\{
|
||||
Query\Select,
|
||||
Query\SelectBuilder,
|
||||
Query\Part\WhereItem,
|
||||
Query\Part\SelectExpression,
|
||||
Query\Part\Selection,
|
||||
Query\Part\Join,
|
||||
Mapper\Mapper,
|
||||
};
|
||||
@@ -315,7 +315,7 @@ class RDBSelectBuilder
|
||||
* * `select(string|Expression $expression, string $alias)`
|
||||
* * `select(SelectExpression $selectItem)`
|
||||
*
|
||||
* @param array|string|Expression|SelectExpression $select An array of expressions or one expression.
|
||||
* @param array|string|Expression|Selection $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
|
||||
|
||||
@@ -33,7 +33,7 @@ use Espo\ORM\{
|
||||
Query\SelectBuilder,
|
||||
Query\Part\Condition as Cond,
|
||||
Query\Part\Expression as Expr,
|
||||
Query\Part\SelectExpression,
|
||||
Query\Part\Selection,
|
||||
Query\Part\OrderExpression,
|
||||
Query\Part\Join,
|
||||
Query\Part\WhereClause,
|
||||
@@ -71,9 +71,9 @@ class SelectBuilderTest extends \PHPUnit\Framework\TestCase
|
||||
|
||||
$this->assertEquals(
|
||||
[
|
||||
SelectExpression::fromString('id'),
|
||||
SelectExpression::fromString('name'),
|
||||
SelectExpression::fromString('test'),
|
||||
Selection::fromString('id'),
|
||||
Selection::fromString('name'),
|
||||
Selection::fromString('test'),
|
||||
],
|
||||
$select->getSelect()
|
||||
);
|
||||
@@ -89,8 +89,8 @@ class SelectBuilderTest extends \PHPUnit\Framework\TestCase
|
||||
|
||||
$this->assertEquals(
|
||||
[
|
||||
SelectExpression::fromString('id'),
|
||||
SelectExpression::fromString('name'),
|
||||
Selection::fromString('id'),
|
||||
Selection::fromString('name'),
|
||||
],
|
||||
$select->getSelect()
|
||||
);
|
||||
@@ -105,7 +105,7 @@ class SelectBuilderTest extends \PHPUnit\Framework\TestCase
|
||||
|
||||
$this->assertEquals(
|
||||
[
|
||||
SelectExpression::fromString('test')->withAlias('hello'),
|
||||
Selection::fromString('test')->withAlias('hello'),
|
||||
],
|
||||
$select->getSelect()
|
||||
);
|
||||
@@ -120,7 +120,7 @@ class SelectBuilderTest extends \PHPUnit\Framework\TestCase
|
||||
|
||||
$this->assertEquals(
|
||||
[
|
||||
SelectExpression::fromString('test')->withAlias('hello'),
|
||||
Selection::fromString('test')->withAlias('hello'),
|
||||
],
|
||||
$select->getSelect()
|
||||
);
|
||||
@@ -136,8 +136,8 @@ class SelectBuilderTest extends \PHPUnit\Framework\TestCase
|
||||
|
||||
$this->assertEquals(
|
||||
[
|
||||
SelectExpression::fromString('id'),
|
||||
SelectExpression::fromString('name'),
|
||||
Selection::fromString('id'),
|
||||
Selection::fromString('name'),
|
||||
],
|
||||
$select->getSelect()
|
||||
);
|
||||
@@ -156,8 +156,8 @@ class SelectBuilderTest extends \PHPUnit\Framework\TestCase
|
||||
|
||||
$this->assertEquals(
|
||||
[
|
||||
SelectExpression::fromString('id')->withAlias('id'),
|
||||
SelectExpression::fromString('name')->withAlias('name'),
|
||||
Selection::fromString('id')->withAlias('id'),
|
||||
Selection::fromString('name')->withAlias('name'),
|
||||
],
|
||||
$select->getSelect()
|
||||
);
|
||||
@@ -169,16 +169,16 @@ class SelectBuilderTest extends \PHPUnit\Framework\TestCase
|
||||
->from('Test')
|
||||
->select([
|
||||
'id',
|
||||
SelectExpression::create(Expr::create('name'))
|
||||
Selection::create(Expr::create('name'))
|
||||
])
|
||||
->select(SelectExpression::fromString('test')->withAlias('testAlias'))
|
||||
->select(Selection::fromString('test')->withAlias('testAlias'))
|
||||
->build();
|
||||
|
||||
$this->assertEquals(
|
||||
[
|
||||
SelectExpression::fromString('id'),
|
||||
SelectExpression::fromString('name'),
|
||||
SelectExpression::fromString('test')->withAlias('testAlias'),
|
||||
Selection::fromString('id'),
|
||||
Selection::fromString('name'),
|
||||
Selection::fromString('test')->withAlias('testAlias'),
|
||||
],
|
||||
$select->getSelect()
|
||||
);
|
||||
|
||||
@@ -36,7 +36,7 @@ use Espo\ORM\{
|
||||
Query\Update,
|
||||
Query\Delete,
|
||||
Query\Union,
|
||||
Query\Part\SelectExpression,
|
||||
Query\Part\Selection,
|
||||
};
|
||||
|
||||
use RuntimeException;
|
||||
@@ -99,8 +99,8 @@ class QueryBuilderTest extends \PHPUnit\Framework\TestCase
|
||||
|
||||
$this->assertEquals(
|
||||
[
|
||||
SelectExpression::fromString('col1'),
|
||||
SelectExpression::fromString('col2'),
|
||||
Selection::fromString('col1'),
|
||||
Selection::fromString('col2'),
|
||||
],
|
||||
$select->getSelect()
|
||||
);
|
||||
@@ -115,7 +115,7 @@ class QueryBuilderTest extends \PHPUnit\Framework\TestCase
|
||||
|
||||
$this->assertEquals(
|
||||
[
|
||||
SelectExpression::fromString('col1')->withAlias('alias1')
|
||||
Selection::fromString('col1')->withAlias('alias1')
|
||||
],
|
||||
$select->getSelect()
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user