From 611aec995456bc96f65f86ad5376b83be446bd22 Mon Sep 17 00:00:00 2001 From: Evgeny Neverov Date: Tue, 20 Feb 2024 12:33:41 +0800 Subject: [PATCH] Bugfix in QueryBuilder::columnPatch Where we have $height === 0 or $distance === 0, QueryBuilder builds SQL expressions like 'when "_rgt" between 12483 and 12496 then "_rgt"0 else "_rgt" end' AND sql server fails at "_rgt"0. Correct behavior is "_rgt" + 0 in that case --- src/QueryBuilder.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/QueryBuilder.php b/src/QueryBuilder.php index 10edb27..a962202 100644 --- a/src/QueryBuilder.php +++ b/src/QueryBuilder.php @@ -654,7 +654,7 @@ protected function columnPatch($col, array $params) extract($params); /** @var int $height */ - if ($height > 0) $height = '+'.$height; + if ($height >= 0) $height = '+'.$height; if (isset($cut)) { return new Expression("case when {$col} >= {$cut} then {$col}{$height} else {$col} end"); @@ -665,7 +665,7 @@ protected function columnPatch($col, array $params) /** @var int $rgt */ /** @var int $from */ /** @var int $to */ - if ($distance > 0) $distance = '+'.$distance; + if ($distance >= 0) $distance = '+'.$distance; return new Expression("case ". "when {$col} between {$lft} and {$rgt} then {$col}{$distance} ". // Move the node