8 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
dc2f27401e Test search data using time with zone 2014-03-15 10:41:12 +08:00
Jinzhu
844a0ddfcc update tests for time with zone 2014-03-15 10:31:26 +08:00
Jinzhu
7bbf71fb29 Add tests to make sure time with zone won't be changed after save 2014-03-15 10:17:43 +08:00
Jinzhu
1086009fce Check if value is struct before check Field 2014-03-11 10:09:16 +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
4c368be254 rename gorm_test to main_test 2014-01-28 16:21:02 +08:00