@@ -26,12 +26,30 @@ const (
2626 None AuthType = "None"
2727)
2828
29+ func tryParseInt (str string ) (int , bool ) {
30+ isInt , err := regexp .MatchString (`[0-9_]*` , str )
31+
32+ if err != nil {
33+ log .Error ("Encountered Error while Parsing Int" , err .Error ())
34+ }
35+
36+ if isInt && err == nil {
37+ intValue , err := strconv .Atoi (str )
38+
39+ if err == nil {
40+ return intValue , true
41+ }
42+ }
43+
44+ return 0 , false
45+ }
46+
2947func parseTypedQuery (values []string ) interface {} {
3048 var result interface {}
3149
3250 raw := values [0 ]
3351
34- intValue , err := strconv . Atoi (raw )
52+ intValue , isInt := tryParseInt (raw )
3553
3654 if strings .Contains (raw , "," ) || (strings .Contains (raw , "[" ) && strings .Contains (raw , "]" )) {
3755 if strings .Contains (raw , "[" ) && strings .Contains (raw , "]" ) {
@@ -45,16 +63,16 @@ func parseTypedQuery(values []string) interface{} {
4563 var list []interface {}
4664
4765 for _ , part := range parts {
48- intVal , err := strconv . Atoi (part )
66+ _intValue , _isInt := tryParseInt (part )
4967
50- if err == nil {
51- list = append (list , intVal )
68+ if _isInt {
69+ list = append (list , _intValue )
5270 } else {
5371 list = append (list , part )
5472 }
5573 }
5674 result = list
57- } else if err == nil {
75+ } else if isInt {
5876 result = intValue
5977 } else {
6078 result = raw
0 commit comments