Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Molakvoæ <skjnldsv@users.noreply.github.com>2021-11-15 23:02:01 +0300
committerGitHub <noreply@github.com>2021-11-15 23:02:01 +0300
commit6bce0d45fc71fb22fe3200a748872c6390441cc7 (patch)
treea2fa0f1f968123e108518e7089b7b57aadd929d3
parent05481edba0447e932b49d83d7b135ae92a856e94 (diff)
parent96c8e0dad3221c11c98fc08f2c2d20a52cc643ba (diff)
Merge pull request #29718 from nextcloud/bump-doctrine-dbal-21
m---------3rdparty0
-rw-r--r--lib/private/DB/Connection.php11
-rw-r--r--lib/private/DB/QueryBuilder/QueryBuilder.php16
-rw-r--r--lib/private/Repair/SqliteAutoincrement.php2
-rw-r--r--lib/public/DB/QueryBuilder/IQueryBuilder.php8
-rw-r--r--lib/public/IDBConnection.php4
-rw-r--r--tests/lib/DB/QueryBuilder/QueryBuilderTest.php10
7 files changed, 28 insertions, 23 deletions
diff --git a/3rdparty b/3rdparty
-Subproject 70082d0507b9479135d1c0157d6c9c2281efb5a
+Subproject fde26117e66ae3556c87a90b63e99a14231949c
diff --git a/lib/private/DB/Connection.php b/lib/private/DB/Connection.php
index cb7af4d51e2..92f89dab5d2 100644
--- a/lib/private/DB/Connection.php
+++ b/lib/private/DB/Connection.php
@@ -184,15 +184,20 @@ class Connection extends ReconnectWrapper {
* Prepares an SQL statement.
*
* @param string $statement The SQL statement to prepare.
- * @param int $limit
- * @param int $offset
+ * @param int|null $limit
+ * @param int|null $offset
*
* @return Statement The prepared statement.
* @throws Exception
*/
public function prepare($statement, $limit = null, $offset = null): Statement {
- if ($limit === -1) {
+ if ($limit === -1 || $limit === null) {
$limit = null;
+ } else {
+ $limit = (int) $limit;
+ }
+ if ($offset !== null) {
+ $offset = (int) $offset;
}
if (!is_null($limit)) {
$platform = $this->getDatabasePlatform();
diff --git a/lib/private/DB/QueryBuilder/QueryBuilder.php b/lib/private/DB/QueryBuilder/QueryBuilder.php
index 352829a56ae..b235745f47b 100644
--- a/lib/private/DB/QueryBuilder/QueryBuilder.php
+++ b/lib/private/DB/QueryBuilder/QueryBuilder.php
@@ -398,21 +398,21 @@ class QueryBuilder implements IQueryBuilder {
/**
* Sets the position of the first result to retrieve (the "offset").
*
- * @param integer $firstResult The first result to return.
+ * @param int $firstResult The first result to return.
*
* @return $this This QueryBuilder instance.
*/
public function setFirstResult($firstResult) {
- $this->queryBuilder->setFirstResult($firstResult);
+ $this->queryBuilder->setFirstResult((int) $firstResult);
return $this;
}
/**
* 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();
@@ -425,12 +425,16 @@ class QueryBuilder implements IQueryBuilder {
* of the databases will just return an empty result set, Oracle will return
* all entries.
*
- * @param integer $maxResults The maximum number of results to retrieve.
+ * @param int|null $maxResults The maximum number of results to retrieve.
*
* @return $this This QueryBuilder instance.
*/
public function setMaxResults($maxResults) {
- $this->queryBuilder->setMaxResults($maxResults);
+ if ($maxResults === null) {
+ $this->queryBuilder->setMaxResults($maxResults);
+ } else {
+ $this->queryBuilder->setMaxResults((int) $maxResults);
+ }
return $this;
}
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 269203ce152..702216e0309 100644
--- a/lib/public/DB/QueryBuilder/IQueryBuilder.php
+++ b/lib/public/DB/QueryBuilder/IQueryBuilder.php
@@ -256,7 +256,7 @@ interface IQueryBuilder {
/**
* Sets the position of the first result to retrieve (the "offset").
*
- * @param integer $firstResult The first result to return.
+ * @param int $firstResult The first result to return.
*
* @return $this This QueryBuilder instance.
* @since 8.2.0
@@ -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();
@@ -275,7 +275,7 @@ interface IQueryBuilder {
/**
* Sets the maximum number of results to retrieve (the "limit").
*
- * @param integer $maxResults The maximum number of results to retrieve.
+ * @param int|null $maxResults The maximum number of results to retrieve.
*
* @return $this This QueryBuilder instance.
* @since 8.2.0
diff --git a/lib/public/IDBConnection.php b/lib/public/IDBConnection.php
index 5618e3ec40b..8761a7e3baa 100644
--- a/lib/public/IDBConnection.php
+++ b/lib/public/IDBConnection.php
@@ -69,8 +69,8 @@ interface IDBConnection {
/**
* Used to abstract the ownCloud database access away
* @param string $sql the sql query with ? placeholder for params
- * @param int $limit the maximum number of rows
- * @param int $offset from which row we want to start
+ * @param int|null $limit the maximum number of rows
+ * @param int|null $offset from which row we want to start
* @return IPreparedStatement The prepared statement.
* @since 6.0.0
* @throws Exception since 21.0.0
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()
);