Describe the feature
The Exec method of the generics API should return the DB interface so that we can use it to get additional information about what was executed.
Motivation
Right now, when using the traditional API, the Exec method returns a DB interface. This is useful when we want to do an UPDATE using Exec and we need the number of rows affected, which we can get from db.RowsAffected.
But the Exec method for the generics API only returns the error, making it impossible to get any information about what was just executed.
See https://github.com/go-gorm/gorm/blob/b289563d54de23e742e2a4cba9d77af01f641b0f/generics.go#L191-L194
My suggestion would be to do this instead
func (c *g[T]) Exec(ctx context.Context, sql string, values ...interface{}) *DB {
var r T
return c.apply(ctx).Model(r).Exec(sql, values...)
}
Related Issues
None