improve multipart form parsing for ghttp.Server

This commit is contained in:
John
2019-11-06 15:37:29 +08:00
parent 6308380541
commit c492de4fa8
5 changed files with 56 additions and 36 deletions

View File

@ -261,10 +261,8 @@ func handlerSliceArguments(query string, args []interface{}) (newQuery string, n
switch kind {
// '?'占位符支持slice类型, 这里会将slice参数拆散并更新原有占位符'?'为多个'?',使用','符号连接。
case reflect.Slice, reflect.Array:
if rv.Len() == 0 {
continue
}
// 不拆分[]byte类型
// 不拆分[]byte类型(当做字符串处理)
// Eg: table.Where("name = ?", []byte("john"))
if _, ok := arg.([]byte); ok {
newArgs = append(newArgs, arg)
continue
@ -274,6 +272,7 @@ func handlerSliceArguments(query string, args []interface{}) (newQuery string, n
}
// 如果参数直接传递slice并且占位符数量与slice长度相等
// 那么不用替换扩展占位符数量直接使用该slice作为查询参数
// Eg: db.Query("SELECT ?+?", g.Slice{1, 2})
if len(args) == 1 && gstr.Count(newQuery, "?") == rv.Len() {
break
}