go-gorm/gorm.io

[Question] Generated SQL not correct for Update Selected Fields

zhangyangyu opened this issue · 0 comments

Document Link

https://github.com/go-gorm/gorm.io/blob/master/pages/docs/update.md#update-selected-fields

Your Question

The Generated SQL omits the updated_at field. For example:

db.Model(&user).Select("name").Updates(map[string]interface{}{"name": "hello", "age": 18, "active": false})

should generate

UPDATE `users` SET `name`="hello",`updated_at`="2024-03-13 16:12:50.555" WHERE `id` = 111

instead of

UPDATE users SET name='hello' WHERE id=111;

Expected answer