5 Commits

Author SHA1 Message Date
Timothy Stranex
27a03477f4 Prevent panic for fields that implement the sql.Scanner interface but are not structs.
Example:

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
}

The model:

type Model struct {
	NamedInt NamedInt `sql:"type:bigint"`
}

Currently, the NamedInt field causes gorm to panic. This change allows it to work as expected.
2014-03-15 21:55:40 +02:00
Jinzhu
24d527670b Use the same database for Related 2014-03-07 19:08:33 +08:00
Jinzhu
2c33502503 Add tests for updated_at will be updated when update value with Assign 2014-02-18 10:03:14 +08:00
Jinzhu
c25f26149e Fix comparing uncomparable type error 2014-01-30 16:41:10 +08:00
Jinzhu
5eed96457b rename couple of scope related methods 2014-01-29 12:00:57 +08:00