2
0

Add simple protocol suuport with (Query|Exec)Ex

This commit is contained in:
Jack Christensen
2017-04-10 08:58:51 -05:00
parent 54d9cbc743
commit 7b1f461ec3
16 changed files with 999 additions and 326 deletions
+19 -2
View File
@@ -121,13 +121,13 @@ func (src *Numeric) AssignTo(dst interface{}) error {
case Present:
switch v := dst.(type) {
case *float32:
f, err := strconv.ParseFloat(src.Int.String(), 64)
f, err := src.toFloat64()
if err != nil {
return err
}
return float64AssignTo(f, src.Status, dst)
case *float64:
f, err := strconv.ParseFloat(src.Int.String(), 64)
f, err := src.toFloat64()
if err != nil {
return err
}
@@ -283,6 +283,23 @@ func (dst *Numeric) toBigInt() (*big.Int, error) {
return num, nil
}
func (src *Numeric) toFloat64() (float64, error) {
f, err := strconv.ParseFloat(src.Int.String(), 64)
if err != nil {
return 0, err
}
if src.Exp > 0 {
for i := 0; i < int(src.Exp); i++ {
f *= 10
}
} else if src.Exp < 0 {
for i := 0; i > int(src.Exp); i-- {
f /= 10
}
}
return f, nil
}
func (dst *Numeric) DecodeText(ci *ConnInfo, src []byte) error {
if src == nil {
*dst = Numeric{Status: Null}