Merge branch 'fix'
This commit is contained in:
@@ -468,7 +468,7 @@ class SelectBuilder
|
||||
$this->withDefaultOrder();
|
||||
}
|
||||
|
||||
if ($this->searchParams->getMaxSize() || $this->searchParams->getOffset()) {
|
||||
if ($this->searchParams->getMaxSize() !== null || $this->searchParams->getOffset() !== null) {
|
||||
$this->createLimitApplier()
|
||||
->apply(
|
||||
$this->queryBuilder,
|
||||
|
||||
@@ -3475,7 +3475,7 @@ abstract class BaseQueryComposer implements QueryComposer
|
||||
$sql .= " ORDER BY {$order}";
|
||||
}
|
||||
|
||||
if ($limit) {
|
||||
if ($limit !== null) {
|
||||
$sql = $this->limit($sql, null, $limit);
|
||||
}
|
||||
|
||||
@@ -3507,7 +3507,7 @@ abstract class BaseQueryComposer implements QueryComposer
|
||||
$sql .= " ORDER BY {$order}";
|
||||
}
|
||||
|
||||
if ($limit) {
|
||||
if ($limit !== null) {
|
||||
$sql = $this->limit($sql, null, $limit);
|
||||
}
|
||||
|
||||
|
||||
Generated
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "espocrm",
|
||||
"version": "7.1.9",
|
||||
"version": "7.1.10",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "espocrm",
|
||||
"version": "7.1.9",
|
||||
"version": "7.1.10",
|
||||
"description": "Open-source CRM.",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
||||
@@ -282,4 +282,23 @@ class SelectBuilderTest extends \PHPUnit\Framework\TestCase
|
||||
|
||||
$this->assertEquals($this->entityType, $query->getFrom());
|
||||
}
|
||||
|
||||
public function testBuildMaxSize0()
|
||||
{
|
||||
|
||||
$searchParams = SearchParams::create()->withMaxSize(0);
|
||||
|
||||
|
||||
$this->limitApplier
|
||||
->expects($this->once())
|
||||
->method('apply')
|
||||
->with($this->isInstanceOf(QueryBuilder::class), 0, 0);
|
||||
|
||||
$query = $this->selectBuilder
|
||||
->from($this->entityType)
|
||||
->withSearchParams($searchParams)
|
||||
->build();
|
||||
|
||||
$this->assertEquals($this->entityType, $query->getFrom());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -150,7 +150,7 @@ class MysqlQueryComposerTest extends \PHPUnit\Framework\TestCase
|
||||
$this->assertEquals($expectedSql, $sql);
|
||||
}
|
||||
|
||||
public function testDeleteWithLimit()
|
||||
public function testDeleteWithLimit1()
|
||||
{
|
||||
$sql = $this->query->compose(Delete::fromRaw([
|
||||
'from' => 'Account',
|
||||
@@ -170,6 +170,26 @@ class MysqlQueryComposerTest extends \PHPUnit\Framework\TestCase
|
||||
$this->assertEquals($expectedSql, $sql);
|
||||
}
|
||||
|
||||
public function testDeleteWithLimit0()
|
||||
{
|
||||
$sql = $this->query->compose(Delete::fromRaw([
|
||||
'from' => 'Account',
|
||||
'whereClause' => [
|
||||
'name' => 'test',
|
||||
],
|
||||
'orderBy' => 'name',
|
||||
'limit' => 0,
|
||||
]));
|
||||
|
||||
$expectedSql =
|
||||
"DELETE FROM `account` " .
|
||||
"WHERE account.name = 'test' " .
|
||||
"ORDER BY account.name ASC " .
|
||||
"LIMIT 0";
|
||||
|
||||
$this->assertEquals($expectedSql, $sql);
|
||||
}
|
||||
|
||||
public function testDeleteWithAlias()
|
||||
{
|
||||
$query = $this->queryBuilder
|
||||
@@ -206,6 +226,28 @@ class MysqlQueryComposerTest extends \PHPUnit\Framework\TestCase
|
||||
$this->assertEquals($expectedSql, $sql);
|
||||
}
|
||||
|
||||
public function testUpdateQuery0()
|
||||
{
|
||||
$sql = $this->query->compose(Update::fromRaw([
|
||||
'from' => 'Account',
|
||||
'whereClause' => [
|
||||
'name' => 'test',
|
||||
],
|
||||
'set' => [
|
||||
'deleted' => false,
|
||||
'name' => 'hello',
|
||||
],
|
||||
'limit' => 0,
|
||||
]));
|
||||
|
||||
$expectedSql =
|
||||
"UPDATE `account` " .
|
||||
"SET account.deleted = 0, account.name = 'hello' ".
|
||||
"WHERE account.name = 'test' LIMIT 0";
|
||||
|
||||
$this->assertEquals($expectedSql, $sql);
|
||||
}
|
||||
|
||||
public function testUpdateQuery1()
|
||||
{
|
||||
$sql = $this->query->compose(Update::fromRaw([
|
||||
@@ -383,6 +425,40 @@ class MysqlQueryComposerTest extends \PHPUnit\Framework\TestCase
|
||||
$this->assertEquals($expectedSql, $sql);
|
||||
}
|
||||
|
||||
public function testSelectLimit1()
|
||||
{
|
||||
$select = $this->queryBuilder
|
||||
->select(['id'])
|
||||
->from('Account')
|
||||
->limit(1, 0)
|
||||
->build();
|
||||
|
||||
$sql = $this->query->compose($select);
|
||||
|
||||
$expectedSql =
|
||||
"SELECT account.id AS `id` FROM `account` " .
|
||||
"WHERE account.deleted = 0 LIMIT 1, 0";
|
||||
|
||||
$this->assertEquals($expectedSql, $sql);
|
||||
}
|
||||
|
||||
public function testSelectLimit2()
|
||||
{
|
||||
$select = $this->queryBuilder
|
||||
->select(['id'])
|
||||
->from('Account')
|
||||
->limit(null, 0)
|
||||
->build();
|
||||
|
||||
$sql = $this->query->compose($select);
|
||||
|
||||
$expectedSql =
|
||||
"SELECT account.id AS `id` FROM `account` " .
|
||||
"WHERE account.deleted = 0 LIMIT 0, 0";
|
||||
|
||||
$this->assertEquals($expectedSql, $sql);
|
||||
}
|
||||
|
||||
public function testSelectAllColumns1()
|
||||
{
|
||||
$select = $this->queryBuilder
|
||||
@@ -2297,7 +2373,7 @@ class MysqlQueryComposerTest extends \PHPUnit\Framework\TestCase
|
||||
->all()
|
||||
->query($q1)
|
||||
->query($q2)
|
||||
->limit(0, 2)
|
||||
->limit(0, 0)
|
||||
->order(1, 'DESC')
|
||||
->build();
|
||||
|
||||
@@ -2308,7 +2384,7 @@ class MysqlQueryComposerTest extends \PHPUnit\Framework\TestCase
|
||||
"UNION ALL ".
|
||||
"(SELECT 'test2' AS `value`) ".
|
||||
"ORDER BY 1 DESC ".
|
||||
"LIMIT 0, 2";
|
||||
"LIMIT 0, 0";
|
||||
|
||||
$this->assertEquals($expectedSql, $sql);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user