orm fixes
This commit is contained in:
@@ -1400,9 +1400,9 @@ abstract class BaseQueryComposer implements QueryComposer
|
||||
if (!empty($defs['select'])) {
|
||||
$expression = $defs['select'];
|
||||
|
||||
if ($alias) {
|
||||
$expression = str_replace('{alias}', $alias, $expression);
|
||||
}
|
||||
$alias = $alias ?? $this->getFromAlias($params, $entity->getEntityType());
|
||||
|
||||
$expression = str_replace('{alias}', $alias, $expression);
|
||||
|
||||
$pair = $this->getSelectPartItemPair($entity, $params, $expression);
|
||||
|
||||
|
||||
@@ -1682,6 +1682,26 @@ class MysqlQueryComposerTest extends \PHPUnit\Framework\TestCase
|
||||
$this->assertEquals($expectedSql, $sql);
|
||||
}
|
||||
|
||||
public function testCustomOrder2()
|
||||
{
|
||||
$queryBuilder = new QueryBuilder();
|
||||
|
||||
$select = $queryBuilder->select()
|
||||
->from('TestSelect')
|
||||
->select(['test'])
|
||||
->order('test')
|
||||
->build();
|
||||
|
||||
$sql = $this->query->compose($select);
|
||||
|
||||
$expectedSql =
|
||||
"SELECT (test_select.id * 1) AS `test` " .
|
||||
"FROM `test_select` " .
|
||||
"ORDER BY (alias.id * 1) ASC";
|
||||
|
||||
$this->assertEquals($expectedSql, $sql);
|
||||
}
|
||||
|
||||
public function testCustomSelect1()
|
||||
{
|
||||
$queryBuilder = new QueryBuilder();
|
||||
@@ -1741,6 +1761,24 @@ class MysqlQueryComposerTest extends \PHPUnit\Framework\TestCase
|
||||
$this->assertEquals($expectedSql, $sql);
|
||||
}
|
||||
|
||||
public function testCustomSelect4()
|
||||
{
|
||||
$queryBuilder = new QueryBuilder();
|
||||
|
||||
$select = $queryBuilder->select()
|
||||
->from('TestSelect')
|
||||
->select(['testAnother'])
|
||||
->build();
|
||||
|
||||
$sql = $this->query->compose($select);
|
||||
|
||||
$expectedSql =
|
||||
"SELECT (test_select.id * 1) AS `testAnother` ".
|
||||
"FROM `test_select`";
|
||||
|
||||
$this->assertEquals($expectedSql, $sql);
|
||||
}
|
||||
|
||||
public function testSelectValue1()
|
||||
{
|
||||
$queryBuilder = new QueryBuilder();
|
||||
|
||||
@@ -522,7 +522,7 @@ return [
|
||||
'type' => Entity::VARCHAR,
|
||||
'notStorable' => true,
|
||||
'select' => [
|
||||
'select' => 'MUL:(id, 1)',
|
||||
'select' => 'MUL:({id, 1)',
|
||||
],
|
||||
'selectForeign' => [
|
||||
'select' => 'MUL:({alias}.id, 1)',
|
||||
@@ -533,6 +533,13 @@ return [
|
||||
],
|
||||
],
|
||||
],
|
||||
'testAnother' => [
|
||||
'type' => Entity::VARCHAR,
|
||||
'notStorable' => true,
|
||||
'select' => [
|
||||
'select' => 'MUL:({alias}.id, 1)',
|
||||
],
|
||||
],
|
||||
],
|
||||
'relations' => [
|
||||
'right' => [
|
||||
|
||||
Reference in New Issue
Block a user