From cd28769e5fcd40d7b0a78f4caa0edd5e123348e7 Mon Sep 17 00:00:00 2001 From: Jinzhu Date: Thu, 20 Jun 2024 19:31:13 +0800 Subject: [PATCH] test map field --- create_test.go | 5 ++++- migrator_test.go | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/create_test.go b/create_test.go index 1435535..db7687f 100644 --- a/create_test.go +++ b/create_test.go @@ -8,7 +8,10 @@ import ( ) func TestCreate(t *testing.T) { - user := User{ID: 1, Name: "create", FirstName: "zhang", LastName: "jinzhu", Age: 18, Active: true, Salary: 8.8888} + user := User{ID: 1, Name: "create", FirstName: "zhang", LastName: "jinzhu", Age: 18, Active: true, Salary: 8.8888, Attrs: map[string]string{ + "a": "a", + "b": "b", + }} if err := DB.Create(&user).Error; err != nil { t.Fatalf("failed to create user, got error %v", err) diff --git a/migrator_test.go b/migrator_test.go index 4e4db1a..fa5bc1c 100644 --- a/migrator_test.go +++ b/migrator_test.go @@ -17,6 +17,7 @@ type User struct { Age int64 `gorm:"type:Nullable(Int64)"` Active bool Salary float32 + Attrs map[string]string `gorm:"type:Map(String,String);"` CreatedAt time.Time UpdatedAt time.Time }