From 50a73f0c894d363860c90b128f83fda9d6498739 Mon Sep 17 00:00:00 2001 From: juanmacias Date: Thu, 2 Apr 2026 10:57:16 +0200 Subject: [PATCH 1/3] Fix buildLimit() silently dropping OFFSET 0 !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) --- src/QueryBuilder/AbstractDQLQueryBuilder.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/QueryBuilder/AbstractDQLQueryBuilder.php b/src/QueryBuilder/AbstractDQLQueryBuilder.php index d55c7a624..fc7b2a234 100644 --- a/src/QueryBuilder/AbstractDQLQueryBuilder.php +++ b/src/QueryBuilder/AbstractDQLQueryBuilder.php @@ -300,7 +300,7 @@ public function buildLimit(ExpressionInterface|int|null $limit, ExpressionInterf . ($limit instanceof ExpressionInterface ? $this->buildExpression($limit) : (string) $limit); } - if (!empty($offset)) { + if ($offset !== null) { $sql .= ' OFFSET ' . ($offset instanceof ExpressionInterface ? $this->buildExpression($offset) : (string) $offset); } From 4d5f5dd755ef1991036d5b7c75986d3b50abd943 Mon Sep 17 00:00:00 2001 From: Sergei Tigrov Date: Mon, 20 Apr 2026 12:23:59 +0700 Subject: [PATCH 2/3] Update parameter comments in DQLQueryBuilderInterface Clarify parameter descriptions for limit and offset. --- src/QueryBuilder/DQLQueryBuilderInterface.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/QueryBuilder/DQLQueryBuilderInterface.php b/src/QueryBuilder/DQLQueryBuilderInterface.php index b024cd6dd..c2debf749 100644 --- a/src/QueryBuilder/DQLQueryBuilderInterface.php +++ b/src/QueryBuilder/DQLQueryBuilderInterface.php @@ -160,9 +160,9 @@ public function buildHaving(array|ExpressionInterface|string|null $condition, ar public function buildJoin(array $joins, array &$params): string; /** - * @param ExpressionInterface|int|null $limit The limit number. + * @param ExpressionInterface|int|null $limit The limit number. For ​​`null`, no limit clause is built. * @see Query::limit() For more details. - * @param ExpressionInterface|int|null $offset The offset number. + * @param ExpressionInterface|int|null $offset The offset number. For ​​`null` or `0`, no offset clause is built. * @see Query::offset() For more details. * * @throws NotSupportedException From 50bd9dec0e130ee96c73cdee1e3169cd23b991b4 Mon Sep 17 00:00:00 2001 From: Sergei Tigrov Date: Mon, 20 Apr 2026 12:25:45 +0700 Subject: [PATCH 3/3] Apply suggestion from @Tigrov --- src/QueryBuilder/AbstractDQLQueryBuilder.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/QueryBuilder/AbstractDQLQueryBuilder.php b/src/QueryBuilder/AbstractDQLQueryBuilder.php index fc7b2a234..d55c7a624 100644 --- a/src/QueryBuilder/AbstractDQLQueryBuilder.php +++ b/src/QueryBuilder/AbstractDQLQueryBuilder.php @@ -300,7 +300,7 @@ public function buildLimit(ExpressionInterface|int|null $limit, ExpressionInterf . ($limit instanceof ExpressionInterface ? $this->buildExpression($limit) : (string) $limit); } - if ($offset !== null) { + if (!empty($offset)) { $sql .= ' OFFSET ' . ($offset instanceof ExpressionInterface ? $this->buildExpression($offset) : (string) $offset); }