diff --git a/db-test/gorm_test.go b/db-test/gorm_test.go index d66d7fa..8cbc956 100644 --- a/db-test/gorm_test.go +++ b/db-test/gorm_test.go @@ -70,7 +70,7 @@ func TestCompositeType(t *testing.T) { } // Create custom composite type. - if err := gormDB.Exec("DROP TYPE IF EXISTS d3money; CREATE TYPE d3money AS (amount VARCHAR, currency VARCHAR);").Error; err != nil { + if err := gormDB.Exec("DROP TYPE IF EXISTS d3money; CREATE TYPE d3money AS (amount DECIMAL, currency VARCHAR);").Error; err != nil { t.Fatalf("Failed to create d3money composite type: %v", err) } @@ -117,7 +117,7 @@ func TestCompositeType(t *testing.T) { // Test direct access to the fields of the composite type. type CompositeFields struct { - Amount string + Amount decimal.Decimal Currency string } @@ -126,7 +126,7 @@ func TestCompositeType(t *testing.T) { t.Errorf("Failed to query account 1: %v", err) } - a1ExpectedFields := CompositeFields{a1.Balance.Decimal().String(), a1.Balance.Currency().UniqueCode()} + a1ExpectedFields := CompositeFields{a1.Balance.Decimal(), a1.Balance.Currency().UniqueCode()} if !reflect.DeepEqual(a1ReadFields, a1ExpectedFields) { t.Errorf("Queried balance fields %+v don't match expected fields %+v", a1ReadFields, a1ExpectedFields) } @@ -136,7 +136,7 @@ func TestCompositeType(t *testing.T) { t.Errorf("Failed to query account 2: %v", err) } - a2ExpectedFields := CompositeFields{a2.Balance.Decimal().String(), ""} + a2ExpectedFields := CompositeFields{a2.Balance.Decimal(), ""} if !reflect.DeepEqual(a2ReadFields, a2ExpectedFields) { t.Errorf("Queried balance fields %+v don't match expected fields %+v", a2ReadFields, a2ExpectedFields) } diff --git a/db-test/schemas.go b/db-test/schemas.go index 7bbb7b5..93e8e68 100644 --- a/db-test/schemas.go +++ b/db-test/schemas.go @@ -7,7 +7,7 @@ import ( ) type TestAccount struct { - ID uint `gorm:"primarykey"` + ID uint `gorm:"primaryKey"` CreatedAt time.Time UpdatedAt time.Time @@ -15,7 +15,7 @@ type TestAccount struct { } type TestAccountCompositeType struct { - ID uint `gorm:"primarykey"` + ID uint `gorm:"primaryKey"` CreatedAt time.Time UpdatedAt time.Time