gorm/schema
piyongcai 380cc64ff5
fix type alias AutoMigrate bug(Add Test Case) (#4888)
* fix type alias AutoMigrate bug. eg

```go
package main

type IDer interface{ GetID() int64 }

// ID will add some method to implement some interface eg: GetID
type ID int64
func (z ID) GetID() int64 { return int64(z) }

type Test struct {
	ID
	Code string `gorm:"size:50"`
	Name string `gorm:"size:50"`
}

func main() {
	db, err := gorm.Open(postgres.New(postgres.Config{
		DSN: `dsn`,
		PreferSimpleProtocol: false,
	}), &gorm.Config{
		Logger:                 logger.Default.LogMode(logger.Info),
		SkipDefaultTransaction: true,
	})
	if err != nil {
		log.Fatal(err)
	}

	if err = db.AutoMigrate(&Test{}); err != nil {
		// invalid embedded struct for Test's field ID, should be struct, but got main.ID
		log.Fatal(err)
	}
}
```

* fix type alias AutoMigrate bug. eg

```go
package main

type IDer interface{ GetID() int64 }

// ID will add some method to implement some interface eg: GetID
type ID int64
func (z ID) GetID() int64 { return int64(z) }

type Test struct {
	ID
	Code string `gorm:"size:50"`
	Name string `gorm:"size:50"`
}

func main() {
	db, err := gorm.Open(postgres.New(postgres.Config{
		DSN:                  `dsn`,
		PreferSimpleProtocol: false,
	}), &gorm.Config{
		Logger:                 logger.Default.LogMode(logger.Info),
		SkipDefaultTransaction: true,
	})
	if err != nil {
		log.Fatal(err)
	}

	if err = db.AutoMigrate(&Test{}); err != nil {
		// invalid embedded struct for Test's field ID, should be struct, but got main.ID
		log.Fatal(err)
	}
}
```

* Add typealis test.

* try to fix golangci-lint
2021-12-10 17:45:36 +08:00
..
callbacks_test.go Rename package name 2020-06-02 09:18:01 +08:00
check.go Optimize parse constraint (#4153) 2021-03-08 10:21:33 +08:00
check_test.go Rename package name 2020-06-02 09:18:01 +08:00
field.go fix type alias AutoMigrate bug(Add Test Case) (#4888) 2021-12-10 17:45:36 +08:00
field_test.go fix type alias AutoMigrate bug(Add Test Case) (#4888) 2021-12-10 17:45:36 +08:00
index.go Add option tag support for index 2020-10-21 20:18:21 +08:00
index_test.go Add option tag support for index 2020-10-21 20:18:21 +08:00
interfaces.go Add GormValuer interface support 2020-08-27 15:03:57 +08:00
model_test.go Fix nested embedded struct, close #3278 2020-08-18 11:21:40 +08:00
naming.go Add SchemaName to NamingStrategy 2021-08-11 16:20:29 +08:00
naming_test.go Add SchemaName to NamingStrategy 2021-08-11 16:20:29 +08:00
relationship.go Fix self-referential belongs to constraint (#4801) 2021-11-08 09:47:29 +08:00
relationship_test.go Fix self-referential belongs to constraint (#4801) 2021-11-08 09:47:29 +08:00
schema.go Stabilize schema.FieldsWithDefaultDBValue's order, close #4643 2021-11-08 20:20:55 +08:00
schema_helper_test.go Fix some typos (#4294) 2021-04-19 21:03:39 +08:00
schema_test.go Fix NamingStrategy with embedded struct, close #3513 2020-09-24 11:32:38 +08:00
utils.go Code optimize (#4415) 2021-06-10 10:21:28 +08:00
utils_test.go Remove autoincrement tag for join table, close #3217 2020-07-31 18:19:25 +08:00