You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: tests/Database/SqlPreprocessor.phpt
+5-1
Original file line number
Diff line number
Diff line change
@@ -79,6 +79,10 @@ test('IN', function () use ($preprocessor) {
79
79
80
80
Assert::same(reformat('SELECT id FROM author WHERE ([a] IN (NULL, ?, ?, ?)) AND (1=0) AND ([c] NOT IN (NULL, ?, ?, ?))'), $sql);
81
81
Assert::same([1, 2, 3, 1, 2, 3], $params);
82
+
83
+
[$sql, $params] = $preprocessor->process(['SELECT * FROM table WHERE ? AND id IN (?) AND ?', ['a' => 111], [3, 4], ['b' => 222]]);
84
+
Assert::same(reformat('SELECT * FROM table WHERE ([a] = ?) AND id IN (?, ?) AND ([b] = ?)'), $sql);
85
+
Assert::same([111, 3, 4, 222], $params);
82
86
});
83
87
84
88
@@ -343,7 +347,7 @@ test('?values', function () use ($preprocessor) {
343
347
344
348
test('automatic detection failed', function () use ($preprocessor) {
345
349
Assert::exception(function () use ($preprocessor) {
346
-
$preprocessor->process(['INSERT INTO author (name) SELECT name FROM user WHERE id IN (?)', [11, 12]]);
350
+
dump($preprocessor->process(['INSERT INTO author (name) SELECT name FROM user WHERE id ?', [11, 12]])); // invalid sql
347
351
}, Nette\InvalidArgumentException::class, 'Automaticaly detected multi-insert, but values aren\'t array. If you need try to change mode like "?[and|or|set|values|order|list]". Mode "values" was used.');
0 commit comments