forked from mirror/gorm
Fix broken tests for postgres
This commit is contained in:
parent
1485f4bce9
commit
321d10b67b
|
@ -3,6 +3,7 @@ package gorm_test
|
|||
import (
|
||||
"database/sql/driver"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"testing"
|
||||
)
|
||||
|
||||
|
@ -51,7 +52,14 @@ func (l ExampleStringSlice) Value() (driver.Value, error) {
|
|||
}
|
||||
|
||||
func (l *ExampleStringSlice) Scan(input interface{}) error {
|
||||
return json.Unmarshal(input.([]byte), l)
|
||||
switch value := input.(type) {
|
||||
case string:
|
||||
return json.Unmarshal([]byte(value), l)
|
||||
case []byte:
|
||||
return json.Unmarshal(value, l)
|
||||
default:
|
||||
return errors.New("not supported")
|
||||
}
|
||||
}
|
||||
|
||||
type ExampleStruct struct {
|
||||
|
@ -66,5 +74,12 @@ func (l ExampleStructSlice) Value() (driver.Value, error) {
|
|||
}
|
||||
|
||||
func (l *ExampleStructSlice) Scan(input interface{}) error {
|
||||
return json.Unmarshal(input.([]byte), l)
|
||||
switch value := input.(type) {
|
||||
case string:
|
||||
return json.Unmarshal([]byte(value), l)
|
||||
case []byte:
|
||||
return json.Unmarshal(value, l)
|
||||
default:
|
||||
return errors.New("not supported")
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue