Skip to content

Breaking change for Updates #1414

@Joenr-going

Description

@Joenr-going

func main() {

r := dal.Use(db).Product
// gorm 原生
db.Updates(&models.Product{ID: 1}) // UPDATE products SET updated_at='2025-12-01 20:54:45.641' WHERE products.deleted_at IS NULL AND id = 1

r.WithContext(context.Background()).Where(r.Code.Eq("0")).Updates(&models.Product{ID: 1})
}

build sql:

gorm.io/gen v0.3.27 UPDATE products SET id=1,updated_at='2025-12-01 20:54:45.647' WHERE products.code = '0' AND products.deleted_at IS NULL

gorm.io/gen v0.3.26 UPDATE products SET updated_at='2025-12-01 20:58:14.691' WHERE products.code = '0' AND products.deleted_at IS NULL AND id = 1

The Updates method can automatically use ID as a condition in v0.3.26,but it is not available in v0.3.27. I think that the case is bad because it should remain the same as Updates of Gorm

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions