Remove unused functions
This commit is contained in:
parent
27ff0fd873
commit
de08656fa3
|
@ -6,13 +6,8 @@ package xorm
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"database/sql"
|
"database/sql"
|
||||||
"fmt"
|
|
||||||
"reflect"
|
|
||||||
"strconv"
|
|
||||||
"time"
|
|
||||||
|
|
||||||
"xorm.io/xorm/core"
|
"xorm.io/xorm/core"
|
||||||
"xorm.io/xorm/schemas"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func (session *Session) queryPreprocess(sqlStr *string, paramStr ...interface{}) {
|
func (session *Session) queryPreprocess(sqlStr *string, paramStr ...interface{}) {
|
||||||
|
@ -75,61 +70,6 @@ func (session *Session) queryRow(sqlStr string, args ...interface{}) *core.Row {
|
||||||
return core.NewRow(session.queryRows(sqlStr, args...))
|
return core.NewRow(session.queryRows(sqlStr, args...))
|
||||||
}
|
}
|
||||||
|
|
||||||
func value2String(rawValue *reflect.Value) (str string, err error) {
|
|
||||||
aa := reflect.TypeOf((*rawValue).Interface())
|
|
||||||
vv := reflect.ValueOf((*rawValue).Interface())
|
|
||||||
switch aa.Kind() {
|
|
||||||
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
|
|
||||||
str = strconv.FormatInt(vv.Int(), 10)
|
|
||||||
case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
|
|
||||||
str = strconv.FormatUint(vv.Uint(), 10)
|
|
||||||
case reflect.Float32, reflect.Float64:
|
|
||||||
str = strconv.FormatFloat(vv.Float(), 'f', -1, 64)
|
|
||||||
case reflect.String:
|
|
||||||
str = vv.String()
|
|
||||||
case reflect.Array, reflect.Slice:
|
|
||||||
switch aa.Elem().Kind() {
|
|
||||||
case reflect.Uint8:
|
|
||||||
data := rawValue.Interface().([]byte)
|
|
||||||
str = string(data)
|
|
||||||
if str == "\x00" {
|
|
||||||
str = "0"
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
err = fmt.Errorf("Unsupported struct type %v as array", vv.Type().Name())
|
|
||||||
}
|
|
||||||
// time type
|
|
||||||
case reflect.Struct:
|
|
||||||
if aa.ConvertibleTo(schemas.TimeType) {
|
|
||||||
str = vv.Convert(schemas.TimeType).Interface().(time.Time).Format(time.RFC3339Nano)
|
|
||||||
} else {
|
|
||||||
err = fmt.Errorf("Unsupported struct type %v as struct", vv.Type().Name())
|
|
||||||
}
|
|
||||||
case reflect.Bool:
|
|
||||||
str = strconv.FormatBool(vv.Bool())
|
|
||||||
case reflect.Complex128, reflect.Complex64:
|
|
||||||
str = fmt.Sprintf("%v", vv.Complex())
|
|
||||||
/* TODO: unsupported types below
|
|
||||||
case reflect.Map:
|
|
||||||
case reflect.Ptr:
|
|
||||||
case reflect.Uintptr:
|
|
||||||
case reflect.UnsafePointer:
|
|
||||||
case reflect.Chan, reflect.Func, reflect.Interface:
|
|
||||||
*/
|
|
||||||
default:
|
|
||||||
err = fmt.Errorf("Unsupported struct type %v as %v", vv.Type().Name(), aa.Kind())
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func value2Bytes(rawValue *reflect.Value) ([]byte, error) {
|
|
||||||
str, err := value2String(rawValue)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return []byte(str), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (session *Session) queryBytes(sqlStr string, args ...interface{}) ([]map[string][]byte, error) {
|
func (session *Session) queryBytes(sqlStr string, args ...interface{}) ([]map[string][]byte, error) {
|
||||||
rows, err := session.queryRows(sqlStr, args...)
|
rows, err := session.queryRows(sqlStr, args...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in New Issue