Skip to content

Generics API: Updates(ctx, map[string]interface{}) fails with type mismatch (cannot use map[string]interface{} as User) #7709

@immortal521

Description

@immortal521

GORM Playground Link

go-gorm/playground#1

Description

On the GORM documentation page (https://gorm.io/docs/update.html#Updates-multiple-columns
), it says the Generics API can update multiple columns using:

rows, err := gorm.G[User](db).Where("id = ?", 111).Updates(ctx, map[string]interface{}{"name": "hello", "age": 18, "active": false})

However, this results in an error:

cannot use map[string]interface{}{} (value of type map[string]interface{}) as User value in argument to gorm.G[User](db).Where("id = ?", 111).Updates [IncompatibleAssign]

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions