Merge 27a03477f4f63b4cbdc8afe41a27ec73e7b07bfd into dc2f27401eb44bb575423b467709f8f529dd9002

This commit is contained in:
Timothy 2014-03-15 20:04:17 +00:00
commit be5cd20731
2 changed files with 12 additions and 1 deletions

View File

@ -22,6 +22,16 @@ type IgnoredEmbedStruct struct {
Name string
}
type NamedInt int64
func (i *NamedInt) Scan(src interface{}) error {
v := reflect.ValueOf(src)
if v.Kind() != reflect.Int64 {
return errors.New("Cannot scan NamedInt from " + v.String())
}
*i = NamedInt(v.Int())
return nil
}
type User struct {
Id int64 // Id: Primary key
Age int64
@ -42,6 +52,7 @@ type User struct {
PasswordHash []byte
IgnoreMe int64 `sql:"-"`
IgnoreStringSlice []string `sql:"-"`
NamedInt NamedInt `sql:"type:bigint"`
}
type CreditCard struct {

View File

@ -309,7 +309,7 @@ func (scope *Scope) sqlTagForField(field *Field) (tag string) {
value := field.Value
reflectValue := reflect.ValueOf(value)
if field.IsScanner() {
if field.IsScanner() && reflectValue.Kind() == reflect.Struct {
value = reflectValue.Field(0).Interface()
}