From 96c8e0dad3221c11c98fc08f2c2d20a52cc643ba Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 15 Nov 2021 19:06:36 +0100 Subject: [PATCH] Apply changes from master's update to 3.1.3 Signed-off-by: Joas Schilling --- lib/private/DB/QueryBuilder/QueryBuilder.php | 4 ++-- lib/private/Repair/SqliteAutoincrement.php | 2 +- lib/public/DB/QueryBuilder/IQueryBuilder.php | 4 ++-- tests/lib/DB/QueryBuilder/QueryBuilderTest.php | 10 +++------- 4 files changed, 8 insertions(+), 12 deletions(-) diff --git a/lib/private/DB/QueryBuilder/QueryBuilder.php b/lib/private/DB/QueryBuilder/QueryBuilder.php index 0a9590aa3d9..b235745f47b 100644 --- a/lib/private/DB/QueryBuilder/QueryBuilder.php +++ b/lib/private/DB/QueryBuilder/QueryBuilder.php @@ -410,9 +410,9 @@ class QueryBuilder implements IQueryBuilder { /** * Gets the position of the first result the query object was set to retrieve (the "offset"). - * Returns NULL if {@link setFirstResult} was not applied to this QueryBuilder. + * Returns 0 if {@link setFirstResult} was not applied to this QueryBuilder. * - * @return integer The position of the first result. + * @return int The position of the first result. */ public function getFirstResult() { return $this->queryBuilder->getFirstResult(); diff --git a/lib/private/Repair/SqliteAutoincrement.php b/lib/private/Repair/SqliteAutoincrement.php index 651a3c144f3..a49a3f45348 100644 --- a/lib/private/Repair/SqliteAutoincrement.php +++ b/lib/private/Repair/SqliteAutoincrement.php @@ -84,7 +84,7 @@ class SqliteAutoincrement implements IRepairStep { foreach ($columnNames as $columnName) { $columnSchema = $tableSchema->getColumn($columnName); $columnDiff = new ColumnDiff($columnSchema->getName(), $columnSchema); - $tableDiff->changedColumns[] = $columnDiff; + $tableDiff->changedColumns[$columnSchema->getName()] = $columnDiff; $schemaDiff->changedTables[] = $tableDiff; } } catch (SchemaException $e) { diff --git a/lib/public/DB/QueryBuilder/IQueryBuilder.php b/lib/public/DB/QueryBuilder/IQueryBuilder.php index fcba00b92b3..702216e0309 100644 --- a/lib/public/DB/QueryBuilder/IQueryBuilder.php +++ b/lib/public/DB/QueryBuilder/IQueryBuilder.php @@ -265,9 +265,9 @@ interface IQueryBuilder { /** * Gets the position of the first result the query object was set to retrieve (the "offset"). - * Returns NULL if {@link setFirstResult} was not applied to this QueryBuilder. + * Returns 0 if {@link setFirstResult} was not applied to this QueryBuilder. * - * @return integer The position of the first result. + * @return int The position of the first result. * @since 8.2.0 */ public function getFirstResult(); diff --git a/tests/lib/DB/QueryBuilder/QueryBuilderTest.php b/tests/lib/DB/QueryBuilder/QueryBuilderTest.php index aef1acc40c1..19278504707 100644 --- a/tests/lib/DB/QueryBuilder/QueryBuilderTest.php +++ b/tests/lib/DB/QueryBuilder/QueryBuilderTest.php @@ -102,7 +102,7 @@ class QueryBuilderTest extends \Test\TestCase { public function dataFirstResult() { return [ - [null, [99, 98, 97, 96, 95, 94, 93, 92, 91]], + [0, [99, 98, 97, 96, 95, 94, 93, 92, 91]], [0, [99, 98, 97, 96, 95, 94, 93, 92, 91]], [1, [98, 97, 96, 95, 94, 93, 92, 91]], [5, [94, 93, 92, 91]], @@ -112,7 +112,7 @@ class QueryBuilderTest extends \Test\TestCase { /** * @dataProvider dataFirstResult * - * @param int $firstResult + * @param int|null $firstResult * @param array $expectedSet */ public function testFirstResult($firstResult, $expectedSet) { @@ -121,14 +121,10 @@ class QueryBuilderTest extends \Test\TestCase { if ($firstResult !== null) { $this->queryBuilder->setFirstResult($firstResult); - - // FIXME Remove this once Doctrine/DBAL is >2.5.1: - // FIXME See https://github.com/doctrine/dbal/pull/782 - $this->queryBuilder->setMaxResults(100); } $this->assertSame( - $firstResult, + $firstResult ?? 0, $this->queryBuilder->getFirstResult() );