Skip to content

Commit

Permalink
test map field
Browse files Browse the repository at this point in the history
  • Loading branch information
jinzhu committed Jun 20, 2024
1 parent 0f1c09d commit cd28769
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
5 changes: 4 additions & 1 deletion create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions migrator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit cd28769

Please sign in to comment.