1
0
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:
David Grudl
2017-07-22 00:11:23 +02:00
parent 3253a5b092
commit d31f2e3dd4
2 changed files with 24 additions and 13 deletions

View File

@@ -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(