Merge pull request #29717 from nextcloud/bump-doctrine-dbal-22

This commit is contained in:
John Molakvoæ 2021-11-15 20:00:59 +01:00 committed by GitHub
commit b5b3a8aa90
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 29 additions and 24 deletions

@ -1 +1 @@
Subproject commit 40760a4a1a27329d466579e360ae199e44f1f914
Subproject commit fd0d5d72f48315cc4f51342dc2d9e82d1dafe0e8

View file

@ -189,15 +189,20 @@ class Connection extends \Doctrine\DBAL\Connection {
* 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();

View file

@ -450,21 +450,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();
@ -477,12 +477,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;
}

View file

@ -83,7 +83,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) {

View file

@ -280,7 +280,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
@ -289,9 +289,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();
@ -299,7 +299,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

View file

@ -86,8 +86,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

View file

@ -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()
);