mirror of
https://github.com/dg/dibi.git
synced 2025-08-12 17:14:16 +02:00
Translator: %i %f throws exception when value is not numeric (BC break)
This commit is contained in:
@@ -497,11 +497,11 @@ Assert::same('INSERT INTO test **Multi-insert array "num%i" is different**', $e-
|
||||
$array6 = [
|
||||
'id' => [1, 2, 3, 4],
|
||||
'text' => ['ahoj', 'jak', 'se', ['SUM(%i)', '5']],
|
||||
'num%i' => ['1', '', 10.3, 1],
|
||||
'num%i' => ['1', '-1', 10.3, 1],
|
||||
];
|
||||
|
||||
Assert::same(
|
||||
reformat('INSERT INTO test ([id], [text], [num]) VALUES (1, \'ahoj\', 1), (2, \'jak\', 0), (3, \'se\', 10), (4, SUM(5), 1)'),
|
||||
reformat('INSERT INTO test ([id], [text], [num]) VALUES (1, \'ahoj\', 1), (2, \'jak\', -1), (3, \'se\', 10), (4, SUM(5), 1)'),
|
||||
$conn->translate('INSERT INTO test %m', $array6)
|
||||
);
|
||||
|
||||
@@ -521,10 +521,13 @@ Assert::same(
|
||||
$conn->translate('INSERT INTO [test.*]')
|
||||
);
|
||||
|
||||
Assert::same(
|
||||
reformat('INSERT INTO 0'),
|
||||
@$conn->translate('INSERT INTO %f', 'ahoj') // triggers warning in PHP 7.1
|
||||
);
|
||||
Assert::exception(function () use ($conn) {
|
||||
$conn->translate('INSERT INTO %i', 'ahoj');
|
||||
}, 'Dibi\Exception', "Expected number, 'ahoj' given.");
|
||||
|
||||
Assert::exception(function () use ($conn) {
|
||||
$conn->translate('INSERT INTO %f', 'ahoj');
|
||||
}, 'Dibi\Exception', "Expected number, 'ahoj' given.");
|
||||
|
||||
|
||||
Assert::same(
|
||||
|
Reference in New Issue
Block a user