refactor for value2String (#713)
This commit is contained in:
parent
d9eb2f5f36
commit
aab77ab84c
|
@ -22,7 +22,7 @@ func (session *Session) Query(sqlStr string, args ...interface{}) ([]map[string]
|
||||||
return session.queryBytes(sqlStr, args...)
|
return session.queryBytes(sqlStr, args...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func reflect2value(rawValue *reflect.Value) (str string, err error) {
|
func value2String(rawValue *reflect.Value) (str string, err error) {
|
||||||
aa := reflect.TypeOf((*rawValue).Interface())
|
aa := reflect.TypeOf((*rawValue).Interface())
|
||||||
vv := reflect.ValueOf((*rawValue).Interface())
|
vv := reflect.ValueOf((*rawValue).Interface())
|
||||||
switch aa.Kind() {
|
switch aa.Kind() {
|
||||||
|
@ -69,14 +69,6 @@ func reflect2value(rawValue *reflect.Value) (str string, err error) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func value2String(rawValue *reflect.Value) (data string, err error) {
|
|
||||||
data, err = reflect2value(rawValue)
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func row2mapStr(rows *core.Rows, fields []string) (resultsMap map[string]string, err error) {
|
func row2mapStr(rows *core.Rows, fields []string) (resultsMap map[string]string, err error) {
|
||||||
result := make(map[string]string)
|
result := make(map[string]string)
|
||||||
scanResultContainers := make([]interface{}, len(fields))
|
scanResultContainers := make([]interface{}, len(fields))
|
||||||
|
|
|
@ -79,14 +79,12 @@ 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 value2Bytes(rawValue *reflect.Value) (data []byte, err error) {
|
func value2Bytes(rawValue *reflect.Value) ([]byte, error) {
|
||||||
var str string
|
str, err := value2String(rawValue)
|
||||||
str, err = reflect2value(rawValue)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return nil, err
|
||||||
}
|
}
|
||||||
data = []byte(str)
|
return []byte(str), nil
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func row2map(rows *core.Rows, fields []string) (resultsMap map[string][]byte, err error) {
|
func row2map(rows *core.Rows, fields []string) (resultsMap map[string][]byte, err error) {
|
||||||
|
|
Loading…
Reference in New Issue