Closed ppanphper closed 1 year ago
我目前的解决方式
可以学习一下mysql组件的写法
~~Can you provide reproduction code? In fact, if not registered, the default clauses will be used. https://github.com/go-gorm/gorm/blob/master/callbacks/callbacks.go#L27~~ No need, I have reproduced.
当我设置WithoutReturning = true 同时使用Scan方法,会出现panic
postgresConfig := postgres.New(postgres.Config{
PreferSimpleProtocol: true,
DSN: dsn,
WithoutReturning: true,
})
db, _ := gorm.Open(postgresConfig, &gorm.Config{})
var data = map[string]interface{}{}
sql := select * from table where condition
db.Raw(sql).Scan(&data)
fns is nil
After this https://github.com/go-gorm/gorm/commit/af3fbdc2fcfface01ce2a0795ee0fac3997ddc8e change, whether to support return is specified by the clauses, which means that we cannot support those that neither support returning (or the user does not want return), nor support database of LastInsertId
cc @jinzhu
GORM Playground Link
https://github.com/go-gorm/playground/pull/1
Description
当设置 WithoutReturning = true
没有执行注册默认callback callbacks.RegisterDefaultCallbacks
select insert等操作会报panic