File tree Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -66,7 +66,7 @@ public function process($params)
6666 $ this ->arrayMode = NULL ;
6767 $ res [] = Nette \Utils \Strings::replace (
6868 $ param ,
69- '~ \'[^ \']*+ \'|"[^"]*+"|\?[a-z]*|^\s*+(?:INSERT|REPLACE)\b|\b(?:SET|WHERE|HAVING|ORDER BY|GROUP BY|KEY UPDATE)(?=[\s?]*+\z )|/\*.*?\*/|--[^\n]*~si ' ,
69+ '~ \'[^ \']*+ \'|"[^"]*+"|\?[a-z]*|^\s*+(?:INSERT|REPLACE)\b|\b(?:SET|WHERE|HAVING|ORDER BY|GROUP BY|KEY UPDATE)(?=\s*\z|\s*\? )|/\*.*?\*/|--[^\n]*~si ' ,
7070 [$ this , 'callback ' ]
7171 );
7272 } else {
Original file line number Diff line number Diff line change @@ -143,6 +143,19 @@ test(function () use ($preprocessor) { // ?order
143143});
144144
145145
146+ test (function () use ($ preprocessor ) { // mix of where & order
147+ list ($ sql , $ params ) = $ preprocessor ->process (['SELECT id FROM author WHERE ? ORDER BY ? ' , [
148+ 'id ' => 1 ,
149+ 'web ' => 'web ' ,
150+ ], [
151+ 'name ' => FALSE ,
152+ ]]);
153+
154+ Assert::same (reformat ("SELECT id FROM author WHERE ([id] = 1) AND ([web] = 'web') ORDER BY [name] DESC " ), $ sql );
155+ Assert::same ([], $ params );
156+ });
157+
158+
146159test (function () use ($ preprocessor ) { // missing parameters
147160 Assert::exception (function () use ($ preprocessor ) {
148161 $ preprocessor ->process (['SELECT id FROM author WHERE id =? OR id = ? ' , 11 ]);
You can’t perform that action at this time.
0 commit comments