From 2061731e2e1e10df86a9acd729171de6ff29a6ca Mon Sep 17 00:00:00 2001 From: Seth Shelnutt Date: Fri, 6 May 2016 09:02:35 -0400 Subject: [PATCH] Update all unit test for AUTO_INCREMENT change --- customize_column_test.go | 6 +++--- main_test.go | 2 +- migration_test.go | 2 +- multi_primary_keys_test.go | 4 ++-- preload_test.go | 4 ++-- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/customize_column_test.go b/customize_column_test.go index 177b4a5d..6bf34c02 100644 --- a/customize_column_test.go +++ b/customize_column_test.go @@ -8,7 +8,7 @@ import ( ) type CustomizeColumn struct { - ID int64 `gorm:"column:mapped_id; primary_key:yes"` + ID int64 `gorm:"column:mapped_id; primary_key:yes; AUTO_INCREMENT"` Name string `gorm:"column:mapped_name"` Date time.Time `gorm:"column:mapped_time"` } @@ -67,12 +67,12 @@ func TestCustomColumnAndIgnoredFieldClash(t *testing.T) { } type CustomizePerson struct { - IdPerson string `gorm:"column:idPerson;primary_key:true"` + IdPerson string `gorm:"column:idPerson;primary_key:true;AUTO_INCREMENT"` Accounts []CustomizeAccount `gorm:"many2many:PersonAccount;associationforeignkey:idAccount;foreignkey:idPerson"` } type CustomizeAccount struct { - IdAccount string `gorm:"column:idAccount;primary_key:true"` + IdAccount string `gorm:"column:idAccount;primary_key:true;AUTO_INCREMENT"` Name string } diff --git a/main_test.go b/main_test.go index 8ac015c8..f9fedb50 100644 --- a/main_test.go +++ b/main_test.go @@ -68,7 +68,7 @@ func OpenTestConnection() (db *gorm.DB, err error) { func TestStringPrimaryKey(t *testing.T) { type UUIDStruct struct { - ID string `gorm:"primary_key"` + ID string `gorm:"primary_key;AUTO_INCREMENT"` Name string } DB.AutoMigrate(&UUIDStruct{}) diff --git a/migration_test.go b/migration_test.go index 38e5c1c2..2821fda3 100644 --- a/migration_test.go +++ b/migration_test.go @@ -130,7 +130,7 @@ func (i *Num) Scan(src interface{}) error { } type Animal struct { - Counter uint64 `gorm:"primary_key:yes"` + Counter uint64 `gorm:"primary_key:yes;AUTO_INCREMENT"` Name string `sql:"DEFAULT:'galeone'"` From string //test reserved sql keyword as field name Age time.Time `sql:"DEFAULT:current_timestamp"` diff --git a/multi_primary_keys_test.go b/multi_primary_keys_test.go index 8b275d18..65ddec01 100644 --- a/multi_primary_keys_test.go +++ b/multi_primary_keys_test.go @@ -8,7 +8,7 @@ import ( ) type Blog struct { - ID uint `gorm:"primary_key"` + ID uint `gorm:"primary_key;AUTO_INCREMENT"` Locale string `gorm:"primary_key"` Subject string Body string @@ -18,7 +18,7 @@ type Blog struct { } type Tag struct { - ID uint `gorm:"primary_key"` + ID uint `gorm:"primary_key;AUTO_INCREMENT"` Locale string `gorm:"primary_key"` Value string Blogs []*Blog `gorm:"many2many:blogs_tags"` diff --git a/preload_test.go b/preload_test.go index 5c49ecc2..fbe61308 100644 --- a/preload_test.go +++ b/preload_test.go @@ -734,12 +734,12 @@ func TestManyToManyPreloadWithMultiPrimaryKeys(t *testing.T) { type ( Level1 struct { - ID uint `gorm:"primary_key;"` + ID uint `gorm:"primary_key;AUTO_INCREMENT"` LanguageCode string `gorm:"primary_key"` Value string } Level2 struct { - ID uint `gorm:"primary_key;"` + ID uint `gorm:"primary_key;AUTO_INCREMENT"` LanguageCode string `gorm:"primary_key"` Value string Level1s []Level1 `gorm:"many2many:levels;"`