Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Made the OFFSET in LIMIT queries non-nullable integer defaulting to 0 #3248

Merged
merged 1 commit into from
Aug 12, 2018

Conversation

morozov
Copy link
Member

@morozov morozov commented Aug 11, 2018

Q A
Type improvement
BC Break yes
Fixed issues none

Semantically, the absence of the offset in a LIMITed query ($offset = null) means "start from the beginning", i.e. with the zero offset. Therefore, $offset = null and $offset = 0 are semantically equivalent.

From the practical standpoint, allowing $offset = null means that we have to cast it to an (int) or consider its nullability during strict comparison.

This patch makes the offset non-nullable defaulting to 0. The usage of the NULL offset in DBAL 2.x will be deprecated in favor of using 0.

{
if ($limit === null && $offset > 0) {
return $query . ' LIMIT -1 OFFSET ' . $offset;
$limit = -1;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not strictly related to the issue, just a code duplication cleanup.

Copy link
Contributor

@Majkl578 Majkl578 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, makes sense.

@morozov morozov merged commit 8578aac into doctrine:develop Aug 12, 2018
@morozov morozov deleted the non-nullable-offset branch August 12, 2018 02:33
morozov added a commit that referenced this pull request Sep 29, 2018
Made the OFFSET in LIMIT queries non-nullable integer defaulting to 0
morozov added a commit that referenced this pull request Oct 7, 2018
Made the OFFSET in LIMIT queries non-nullable integer defaulting to 0
morozov added a commit that referenced this pull request Oct 7, 2018
Made the OFFSET in LIMIT queries non-nullable integer defaulting to 0
morozov added a commit that referenced this pull request Nov 14, 2018
Made the OFFSET in LIMIT queries non-nullable integer defaulting to 0
morozov added a commit that referenced this pull request Nov 14, 2018
Made the OFFSET in LIMIT queries non-nullable integer defaulting to 0
morozov added a commit that referenced this pull request Nov 25, 2018
Made the OFFSET in LIMIT queries non-nullable integer defaulting to 0
morozov added a commit that referenced this pull request Dec 6, 2018
Made the OFFSET in LIMIT queries non-nullable integer defaulting to 0
morozov added a commit that referenced this pull request Jan 20, 2019
Made the OFFSET in LIMIT queries non-nullable integer defaulting to 0
morozov added a commit to morozov/dbal that referenced this pull request Feb 6, 2019
Made the OFFSET in LIMIT queries non-nullable integer defaulting to 0
morozov added a commit to morozov/dbal that referenced this pull request Feb 6, 2019
Made the OFFSET in LIMIT queries non-nullable integer defaulting to 0
morozov added a commit that referenced this pull request Feb 7, 2019
Made the OFFSET in LIMIT queries non-nullable integer defaulting to 0
morozov added a commit that referenced this pull request Feb 20, 2019
Made the OFFSET in LIMIT queries non-nullable integer defaulting to 0
morozov added a commit that referenced this pull request Feb 22, 2019
Made the OFFSET in LIMIT queries non-nullable integer defaulting to 0
morozov added a commit that referenced this pull request Mar 15, 2019
Made the OFFSET in LIMIT queries non-nullable integer defaulting to 0
morozov added a commit that referenced this pull request Mar 15, 2019
Made the OFFSET in LIMIT queries non-nullable integer defaulting to 0
morozov added a commit that referenced this pull request Mar 18, 2019
Made the OFFSET in LIMIT queries non-nullable integer defaulting to 0
morozov added a commit that referenced this pull request Apr 16, 2019
Made the OFFSET in LIMIT queries non-nullable integer defaulting to 0
morozov added a commit that referenced this pull request May 6, 2019
Made the OFFSET in LIMIT queries non-nullable integer defaulting to 0
morozov added a commit that referenced this pull request May 23, 2019
Made the OFFSET in LIMIT queries non-nullable integer defaulting to 0
morozov added a commit to morozov/dbal that referenced this pull request May 31, 2019
Made the OFFSET in LIMIT queries non-nullable integer defaulting to 0
morozov added a commit that referenced this pull request Jun 13, 2019
Made the OFFSET in LIMIT queries non-nullable integer defaulting to 0
morozov added a commit that referenced this pull request Jun 27, 2019
Made the OFFSET in LIMIT queries non-nullable integer defaulting to 0
morozov added a commit to morozov/dbal that referenced this pull request Aug 26, 2019
Made the OFFSET in LIMIT queries non-nullable integer defaulting to 0
morozov added a commit that referenced this pull request Nov 2, 2019
Made the OFFSET in LIMIT queries non-nullable integer defaulting to 0
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 11, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants