Fix TestPostgresReturningMultipleColumns error
This commit is contained in:
parent
656b6e22e4
commit
48c265249c
@ -1,12 +1,11 @@
|
|||||||
package gorm_test
|
package gorm_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"github.com/jinzhu/now"
|
||||||
"os"
|
"os"
|
||||||
"reflect"
|
"reflect"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/jinzhu/now"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestCreate(t *testing.T) {
|
func TestCreate(t *testing.T) {
|
||||||
@ -288,35 +287,35 @@ func TestCreateIgnore(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestPostgresReturningMultipleColumns(t *testing.T) {
|
func TestPostgresReturningMultipleColumns(t *testing.T) {
|
||||||
type ReturningMultipleColumns struct {
|
if DB.Dialect().GetName() == "postgres" {
|
||||||
ID uint `gorm:"primary_key"`
|
type ReturningMultipleColumns struct {
|
||||||
SerialA int `gorm:"type:serial;not null"`
|
ID uint `gorm:"primary_key"`
|
||||||
SerialB int `gorm:"type:serial;not null"`
|
SerialA int `gorm:"type:serial;not null"`
|
||||||
SerialC int `gorm:"type:serial;not null"`
|
SerialB int `gorm:"type:serial;not null"`
|
||||||
}
|
SerialC int `gorm:"type:serial;not null"`
|
||||||
|
}
|
||||||
|
|
||||||
DB.LogMode(true)
|
err := DB.AutoMigrate(&ReturningMultipleColumns{}).Error
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
err := DB.AutoMigrate(&ReturningMultipleColumns{}).Error
|
record := ReturningMultipleColumns{}
|
||||||
if err != nil {
|
err = DB.Omit("serial_a", "serial_b", "serial_c").Create(&record).Error
|
||||||
t.Fatal(err)
|
if err != nil {
|
||||||
}
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
record := ReturningMultipleColumns{}
|
if record.SerialA == 0 {
|
||||||
err = DB.Omit("serial_a", "serial_b", "serial_c").Create(&record).Error
|
t.Error("SerialA should not be 0")
|
||||||
if err != nil {
|
}
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if record.SerialA == 0 {
|
if record.SerialB == 0 {
|
||||||
t.Error("SerialA should not be 0")
|
t.Error("SerialB should not be 0")
|
||||||
}
|
}
|
||||||
|
|
||||||
if record.SerialB == 0 {
|
if record.SerialC == 0 {
|
||||||
t.Error("SerialB should not be 0")
|
t.Error("SerialC should not be 0")
|
||||||
}
|
}
|
||||||
|
|
||||||
if record.SerialC == 0 {
|
|
||||||
t.Error("SerialC should not be 0")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user