Skip to content

Commit

Permalink
Add test showing MSSQL issue
Browse files Browse the repository at this point in the history
  • Loading branch information
sblackstone committed Jan 5, 2024
1 parent e5208c4 commit 664b8f3
Showing 1 changed file with 24 additions and 5 deletions.
29 changes: 24 additions & 5 deletions main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,32 @@ import (
// GORM_BRANCH: master
// TEST_DRIVERS: sqlite, mysql, postgres, sqlserver

type MultiTable struct {
Field1 string `gorm:"primarykey"`
Field2 string `gorm:"primarykey"`
Field3 string `gorm:"primarykey"`
}

func TestGORM(t *testing.T) {
user := User{Name: "jinzhu"}

DB.Create(&user)
if err := DB.AutoMigrate(&MultiTable{}); err != nil {
t.Fatalf("couldnt create multi_table")
}

var result User
if err := DB.First(&result, user.ID).Error; err != nil {
t.Errorf("Failed, got error: %v", err)
DB.Exec("delete from multi_tables")

rec := MultiTable{
Field1: "val1",
Field2: "val2",
Field3: "val3",
}

if err := DB.Create(&rec).Error; err != nil {
t.Error(err)
}

if err := DB.Delete(&rec).Error; err != nil {
t.Error(err)
}

}

0 comments on commit 664b8f3

Please sign in to comment.