go-gorm / gorm

The fantastic ORM library for Golang, aims to be developer friendly
https://gorm.io
MIT License
36.47k stars 3.9k forks source link

表字段的数据类型定义错误,更新生成SQL不正确,gorm没有报告错误 #7114

Closed shinkeika closed 4 days ago

shinkeika commented 1 month ago

gorm 版本 v1


type Player struct {
        Id int64
        age string
    }

player := Player{}
orm.Find(&player,1).Error

orm.Debug().Model(&player).Updates(map[string]interface{}{"age": "86aaa"}).Error
``

生成的sql 是 
UPDATE `player` SET `age` = '86aaa' WHERE id = 1;

**重点**:实际数据库的 age 字段类型是int

这样最终会导致id为1 的记录 age更新为86的记录,而不是86aaa,而没有任何报错,这是为什么呢?
github-actions[bot] commented 1 month ago

The issue has been automatically marked as stale as it missing playground pull request link, which is important to help others understand your issue effectively and make sure the issue hasn't been fixed on latest master, checkout https://github.com/go-gorm/playground for details. it will be closed in 30 days if no further activity occurs. if you are asking question, please use the Question template, most likely your question already answered https://github.com/go-gorm/gorm/issues or described in the document https://gorm.ioSearch Before Asking