Fix buildLimit() silently dropping OFFSET 0#1173
Open
darkspock wants to merge 1 commit intoyiisoft:masterfrom
Open
Fix buildLimit() silently dropping OFFSET 0#1173darkspock wants to merge 1 commit intoyiisoft:masterfrom
darkspock wants to merge 1 commit intoyiisoft:masterfrom
Conversation
!empty($offset) evaluates to false when $offset is integer 0, causing OFFSET 0 to be silently omitted from the generated SQL. While OFFSET 0 has no semantic effect, this is inconsistent: an explicitly set offset should appear in the output. Replace with $offset !== null which correctly distinguishes "no offset" (null) from "offset zero" (0). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1173 +/- ##
============================================
- Coverage 98.62% 97.83% -0.80%
Complexity 1645 1645
============================================
Files 120 120
Lines 4292 4292
============================================
- Hits 4233 4199 -34
- Misses 59 93 +34 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Tigrov
reviewed
Apr 2, 2026
| } | ||
|
|
||
| if (!empty($offset)) { | ||
| if ($offset !== null) { |
Member
There was a problem hiding this comment.
I don't think this change is necessary. At least if there is no real case where it is needed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
AbstractDQLQueryBuilder::buildLimit()uses!empty($offset)to decide whether to append the OFFSET clause. Sinceempty(0)returnstruein PHP, an explicitly setOFFSET 0is silently dropped from the generated SQL.While
OFFSET 0has no semantic effect on query results, this is inconsistent: a value explicitly set by the caller should be reflected in the output. It can also cause confusion when debugging generated SQL.Fix
Replace
!empty($offset)with$offset !== null, which correctly distinguishes "no offset set" (null) from "offset is zero" (0).Before
After
Risk
Very low — the only change is that
OFFSET 0now appears in the SQL when explicitly set. This has no effect on query results.