File tree Expand file tree Collapse file tree 1 file changed +11
-4
lines changed Expand file tree Collapse file tree 1 file changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -269,17 +269,24 @@ func countParams(queryStmt *sql.Stmt, queryString string) int {
269
269
}
270
270
271
271
// Query returned an error
272
- // Parse the error to get expected params count
273
- regex := regexp .MustCompile (`sql: expected (\d+ ) arguments, got 0` )
272
+ // Parse the error to get the expected params count
273
+ regex := regexp .MustCompile (`sql: expected (\p{N} ) arguments, got 0` )
274
274
regexSubmatches := regex .FindAllStringSubmatch (err .Error (), 1 )
275
275
if len (regexSubmatches ) != 1 || len (regexSubmatches [0 ]) != 2 {
276
- // This is weird, return best guess
276
+ // This is weird
277
+ // queryStmt is prepared (compiled) so it is valid
278
+ // but yet there was an error executing queryStmt
279
+ // Return best guess
280
+ // TODO: Should we maybe return an error and kill the server?
277
281
return strings .Count (queryString , "?" )
278
282
}
279
283
count , err := strconv .Atoi (regexSubmatches [0 ][1 ])
280
284
if err != nil {
281
- // This is weirder because the regex is \d+
285
+ // This is even weirder
286
+ // The regex is \p{N}+ (unicode number sequence) and there was a match,
287
+ // but converting it from string to int returned an error
282
288
// Return best guess
289
+ // TODO: Should we maybe return an error and kill the server?
283
290
return strings .Count (queryString , "?" )
284
291
}
285
292
return count
You can’t perform that action at this time.
0 commit comments