From ffe84a5ac893921af71103db9bea5d676ab687c9 Mon Sep 17 00:00:00 2001 From: mikcl Date: Tue, 10 Sep 2024 22:08:25 +0100 Subject: [PATCH 1/2] array insertion failure --- main_test.go | 2 +- models.go | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/main_test.go b/main_test.go index 60a388f7..01e631c1 100644 --- a/main_test.go +++ b/main_test.go @@ -9,7 +9,7 @@ import ( // TEST_DRIVERS: sqlite, mysql, postgres, sqlserver func TestGORM(t *testing.T) { - user := User{Name: "jinzhu"} + user := User{Name: "jinzhu", Emails: []string{"dummy-email"}} DB.Create(&user) diff --git a/models.go b/models.go index 692a6842..2cd48765 100644 --- a/models.go +++ b/models.go @@ -15,6 +15,7 @@ type User struct { gorm.Model Name string Age uint + Emails []string Birthday *time.Time Account Account Pets []*Pet From 78bbca220216ad852a4e4c1658c780efc35fbb2c Mon Sep 17 00:00:00 2001 From: mikcl Date: Tue, 10 Sep 2024 23:38:22 +0100 Subject: [PATCH 2/2] clarify type text[] --- models.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/models.go b/models.go index 2cd48765..32a0bee8 100644 --- a/models.go +++ b/models.go @@ -15,7 +15,7 @@ type User struct { gorm.Model Name string Age uint - Emails []string + Emails []string `gorm:"type:text[]"` Birthday *time.Time Account Account Pets []*Pet