GORM Playground Link
https://github.com/go-gorm/playground/pull/1
Description
gorm version
go 1.16
require (
gorm.io/driver/mysql v1.4.3
gorm.io/gorm v1.23.10
)
reproduce Execute the following sql, mysql client returns an error:
mysql> SELECT 9223372036854775807 + 1;
ERROR 1690 (22003): BIGINT value is out of range in '(9223372036854775807 + 1)'
However, gorm cannot catch this error:
import (
"fmt"
// "database/sql"
// _ "github.com/go-sql-driver/mysql"
"gorm.io/driver/mysql"
"gorm.io/gorm"
"log"
)
func main() {
// sudo docker run -itd --name test -p 13306:3306 -e MYSQL_ROOT_PASSWORD=123456 mysql
dsn := fmt.Sprintf("%s:%s@tcp(%s:%d)/%s?charset=utf8&parseTime=True&loc=Local",
"root", "123456", "127.0.0.1", 13306, "TEST")
db, err := gorm.Open(mysql.Open(dsn))
if err != nil {
log.Fatal(err)
}
rows, err := db.Raw("SELECT 9223372036854775807 + 1").Rows()
if err != nil { // ==================== no error ====================
log.Fatal(err)
}
fmt.Println("ok")
_ = rows.Close()
}
Besides, I tried database/sql with github.com/go-sql-driver/mysql, it also failed to catch this error.
Something wrong with mysql driver?
Comment From: github-actions[bot]
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.io ✨ Search Before Asking ✨
Comment From: qaqcatz
I will close this issue and report the problem to https://github.com/go-sql-driver/mysql