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)
66
66
$ this ->arrayMode = NULL ;
67
67
$ res [] = Nette \Utils \Strings::replace (
68
68
$ 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 ' ,
70
70
[$ this , 'callback ' ]
71
71
);
72
72
} else {
Original file line number Diff line number Diff line change @@ -143,6 +143,19 @@ test(function () use ($preprocessor) { // ?order
143
143
});
144
144
145
145
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
+
146
159
test (function () use ($ preprocessor ) { // missing parameters
147
160
Assert::exception (function () use ($ preprocessor ) {
148
161
$ preprocessor ->process (['SELECT id FROM author WHERE id =? OR id = ? ' , 11 ]);
You can’t perform that action at this time.
0 commit comments