mirror of
https://github.com/bitechdev/ResolveSpec.git
synced 2026-01-16 16:04:25 +00:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a980201d21 |
@@ -74,6 +74,10 @@ func (n *SqlNull[T]) Scan(value any) error {
|
|||||||
return n.FromString(v)
|
return n.FromString(v)
|
||||||
case []byte:
|
case []byte:
|
||||||
return n.FromString(string(v))
|
return n.FromString(string(v))
|
||||||
|
case float32, float64:
|
||||||
|
return n.FromString(fmt.Sprintf("%f", value))
|
||||||
|
case int, int8, int16, int32, int64, uint, uint8, uint16, uint32, uint64:
|
||||||
|
return n.FromString(fmt.Sprintf("%d", value))
|
||||||
default:
|
default:
|
||||||
return n.FromString(fmt.Sprintf("%v", value))
|
return n.FromString(fmt.Sprintf("%v", value))
|
||||||
}
|
}
|
||||||
@@ -94,6 +98,10 @@ func (n *SqlNull[T]) FromString(s string) error {
|
|||||||
reflect.ValueOf(&n.Val).Elem().SetInt(i)
|
reflect.ValueOf(&n.Val).Elem().SetInt(i)
|
||||||
n.Valid = true
|
n.Valid = true
|
||||||
}
|
}
|
||||||
|
if f, err := strconv.ParseFloat(s, 64); err == nil {
|
||||||
|
reflect.ValueOf(&n.Val).Elem().SetInt(int64(f))
|
||||||
|
n.Valid = true
|
||||||
|
}
|
||||||
case float32, float64:
|
case float32, float64:
|
||||||
if f, err := strconv.ParseFloat(s, 64); err == nil {
|
if f, err := strconv.ParseFloat(s, 64); err == nil {
|
||||||
reflect.ValueOf(&n.Val).Elem().SetFloat(f)
|
reflect.ValueOf(&n.Val).Elem().SetFloat(f)
|
||||||
|
|||||||
Reference in New Issue
Block a user