orm support use any numeric type set QuerySeter.Limit value

This commit is contained in:
slene
2013-09-13 18:06:44 +08:00
parent 8e8d39d3cb
commit 1596aa7a34
4 changed files with 21 additions and 16 deletions

View File

@@ -2,6 +2,7 @@ package orm
import (
"fmt"
"reflect"
"strconv"
"strings"
"time"
@@ -133,6 +134,19 @@ func ToStr(value interface{}, args ...int) (s string) {
return s
}
func ToInt64(value interface{}) (d int64) {
val := reflect.ValueOf(value)
switch value.(type) {
case int, int8, int16, int32, int64:
d = val.Int()
case uint, uint8, uint16, uint32, uint64:
d = int64(val.Uint())
default:
panic(fmt.Errorf("ToInt64 need numeric not `%T`", value))
}
return
}
func snakeString(s string) string {
data := make([]byte, 0, len(s)*2)
j := false