Skip to content

Commit 6ca8dcd

Browse files
committed
Add negative multiplier/divisor support to SQLite adapter
Apply same sign-aware overflow/underflow checks as Postgres and MariaDB
1 parent f6f7613 commit 6ca8dcd

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/Database/Adapter/SQLite.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1485,7 +1485,8 @@ protected function getOperatorSQL(string $column, Operator $operator, int &$bind
14851485
$bindIndex++;
14861486
return "{$quotedColumn} = CASE
14871487
WHEN COALESCE({$quotedColumn}, 0) >= :$maxKey THEN :$maxKey
1488-
WHEN :$bindKey != 0 AND COALESCE({$quotedColumn}, 0) > :$maxKey / :$bindKey THEN :$maxKey
1488+
WHEN :$bindKey > 0 AND COALESCE({$quotedColumn}, 0) > :$maxKey / :$bindKey THEN :$maxKey
1489+
WHEN :$bindKey < 0 AND COALESCE({$quotedColumn}, 0) < :$maxKey / :$bindKey THEN :$maxKey
14891490
ELSE COALESCE({$quotedColumn}, 0) * :$bindKey
14901491
END";
14911492
}
@@ -1501,7 +1502,8 @@ protected function getOperatorSQL(string $column, Operator $operator, int &$bind
15011502
$bindIndex++;
15021503
return "{$quotedColumn} = CASE
15031504
WHEN COALESCE({$quotedColumn}, 0) <= :$minKey THEN :$minKey
1504-
WHEN :$bindKey != 0 AND COALESCE({$quotedColumn}, 0) < :$minKey * :$bindKey THEN :$minKey
1505+
WHEN :$bindKey > 0 AND COALESCE({$quotedColumn}, 0) < :$minKey * :$bindKey THEN :$minKey
1506+
WHEN :$bindKey < 0 AND COALESCE({$quotedColumn}, 0) > :$minKey * :$bindKey THEN :$minKey
15051507
ELSE COALESCE({$quotedColumn}, 0) / :$bindKey
15061508
END";
15071509
}

0 commit comments

Comments
 (0)