Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
doctrine-dbal
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Tomáš Trávníček
doctrine-dbal
Commits
7027ec99
Unverified
Commit
7027ec99
authored
Jan 22, 2020
by
Sergei Morozov
Committed by
GitHub
Jan 22, 2020
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3840 from morozov/max-results-null
Fixed the QueryBuilder::setMaxResults() signature to accept NULL
parents
4d9a08cc
bf2dc106
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
8 deletions
+21
-8
QueryBuilder.php
lib/Doctrine/DBAL/Query/QueryBuilder.php
+4
-5
QueryBuilderTest.php
tests/Doctrine/Tests/DBAL/Query/QueryBuilderTest.php
+17
-3
No files found.
lib/Doctrine/DBAL/Query/QueryBuilder.php
View file @
7027ec99
...
...
@@ -122,7 +122,7 @@ class QueryBuilder
private
$firstResult
=
0
;
/**
* The maximum number of results to retrieve.
* The maximum number of results to retrieve
or NULL to retrieve all results
.
*
* @var int|null
*/
...
...
@@ -365,7 +365,6 @@ class QueryBuilder
/**
* 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.
*
* @return int The position of the first result.
*/
...
...
@@ -377,11 +376,11 @@ class QueryBuilder
/**
* Sets the maximum number of results to retrieve (the "limit").
*
* @param int
$maxResults The maximum number of results to retrieve
.
* @param int
|null $maxResults The maximum number of results to retrieve or NULL to retrieve all results
.
*
* @return $this This QueryBuilder instance.
*/
public
function
setMaxResults
(
int
$maxResults
)
:
self
public
function
setMaxResults
(
?
int
$maxResults
)
:
self
{
$this
->
state
=
self
::
STATE_DIRTY
;
$this
->
maxResults
=
$maxResults
;
...
...
@@ -391,7 +390,7 @@ class QueryBuilder
/**
* Gets the maximum number of results the query object was set to retrieve (the "limit").
* Returns NULL if
{@link setMaxResults} was not applied to this query builder
.
* Returns NULL if
all results will be returned
.
*
* @return int|null The maximum number of results.
*/
...
...
tests/Doctrine/Tests/DBAL/Query/QueryBuilderTest.php
View file @
7027ec99
...
...
@@ -474,13 +474,27 @@ class QueryBuilderTest extends DbalTestCase
self
::
assertEquals
(
$sql1
,
$qb
->
getSQL
());
}
public
function
testSetMaxResults
()
:
void
/**
* @dataProvider maxResultsProvider
*/
public
function
testSetMaxResults
(
?
int
$maxResults
)
:
void
{
$qb
=
new
QueryBuilder
(
$this
->
conn
);
$qb
->
setMaxResults
(
10
);
$qb
->
setMaxResults
(
$maxResults
);
self
::
assertEquals
(
QueryBuilder
::
STATE_DIRTY
,
$qb
->
getState
());
self
::
assertEquals
(
10
,
$qb
->
getMaxResults
());
self
::
assertEquals
(
$maxResults
,
$qb
->
getMaxResults
());
}
/**
* @return mixed[][]
*/
public
static
function
maxResultsProvider
()
:
iterable
{
return
[
'non-null'
=>
[
10
],
'null'
=>
[
null
],
];
}
public
function
testSetFirstResult
()
:
void
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment