File tree Expand file tree Collapse file tree 1 file changed +19
-5
lines changed Expand file tree Collapse file tree 1 file changed +19
-5
lines changed Original file line number Diff line number Diff line change @@ -1359,14 +1359,28 @@ type DoubleInt64 struct {
13591359 data int64
13601360}
13611361
1362- func (t * DoubleInt64 ) Scan (val interface {}) error {
1363- switch v := val .(type ) {
1364- case int64 :
1365- t .data = v * 2
1362+ func (t * DoubleInt64 ) Scan (v any ) error {
1363+ if v == nil {
1364+ t .data = 0
13661365 return nil
1366+ }
1367+ switch x := v .(type ) {
1368+ case int64 :
1369+ t .data = x * 2
1370+ case float64 :
1371+ t .data = int64 (x ) * 2
13671372 default :
1368- return fmt .Errorf ("DoubleInt64 cant not scan with:%v" , v )
1373+ if s , ok := x .(fmt.Stringer ); ok { // e.g., godror.Number
1374+ n , err := strconv .ParseInt (strings .TrimSpace (s .String ()), 10 , 64 )
1375+ if err != nil {
1376+ return fmt .Errorf ("DoubleInt64: %w" , err )
1377+ }
1378+ t .data = n * 2
1379+ return nil
1380+ }
1381+ return fmt .Errorf ("DoubleInt64: cannot scan %T" , v )
13691382 }
1383+ return nil
13701384}
13711385
13721386// https://github.com/go-gorm/gorm/issues/5091
You can’t perform that action at this time.
0 commit comments