mirror of
https://gitee.com/johng/gf.git
synced 2024-11-29 18:57:44 +08:00
parent
6fb26c44d7
commit
3991eb053c
43
contrib/drivers/clickhouse/clickhouse_issue_test.go
Normal file
43
contrib/drivers/clickhouse/clickhouse_issue_test.go
Normal file
@ -0,0 +1,43 @@
|
||||
// Copyright GoFrame Author(https://goframe.org). All Rights Reserved.
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the MIT License.
|
||||
// If a copy of the MIT was not distributed with this file,
|
||||
// You can obtain one at https://github.com/gogf/gf.
|
||||
|
||||
package clickhouse
|
||||
|
||||
import (
|
||||
"github.com/shopspring/decimal"
|
||||
"testing"
|
||||
|
||||
"github.com/gogf/gf/v2/container/gvar"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"github.com/gogf/gf/v2/test/gtest"
|
||||
"github.com/gogf/gf/v2/util/gconv"
|
||||
)
|
||||
|
||||
func Test_Issue2584(t *testing.T) {
|
||||
type TDecimal struct {
|
||||
F1 *decimal.Decimal `json:"f1"`
|
||||
}
|
||||
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
var (
|
||||
p1 = TDecimal{}
|
||||
data1 = g.Map{"f1": gvar.New(1111.111)}
|
||||
err = gconv.Scan(data1, &p1)
|
||||
)
|
||||
t.AssertNil(err)
|
||||
t.Assert(p1.F1, 1111.111)
|
||||
})
|
||||
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
var (
|
||||
p2 = TDecimal{}
|
||||
data2 = g.Map{"f1": gvar.New("2222.222")}
|
||||
err = gconv.Scan(data2, &p2)
|
||||
)
|
||||
t.AssertNil(err)
|
||||
t.Assert(p2.F1, 2222.222)
|
||||
})
|
||||
}
|
@ -422,6 +422,8 @@ func bindVarToReflectValueWithInterfaceCheck(reflectValue reflect.Value, value i
|
||||
valueBytes = b
|
||||
} else if s, ok := value.(string); ok {
|
||||
valueBytes = []byte(s)
|
||||
} else if f, ok := value.(iString); ok {
|
||||
valueBytes = []byte(f.String())
|
||||
}
|
||||
if len(valueBytes) > 0 {
|
||||
return v.UnmarshalText(valueBytes), ok
|
||||
@ -434,6 +436,8 @@ func bindVarToReflectValueWithInterfaceCheck(reflectValue reflect.Value, value i
|
||||
valueBytes = b
|
||||
} else if s, ok := value.(string); ok {
|
||||
valueBytes = []byte(s)
|
||||
} else if f, ok := value.(iString); ok {
|
||||
valueBytes = []byte(f.String())
|
||||
}
|
||||
|
||||
if len(valueBytes) > 0 {
|
||||
|
Loading…
Reference in New Issue
Block a user