gorm/callbacks/row.go

18 lines
466 B
Go
Raw Normal View History

2020-02-22 14:41:01 +03:00
package callbacks
import (
"github.com/jinzhu/gorm"
)
func RowQuery(db *gorm.DB) {
2020-02-22 15:57:29 +03:00
if db.Statement.SQL.String() == "" {
2020-05-31 14:23:32 +03:00
BuildQuerySQL(db)
2020-02-22 15:57:29 +03:00
}
2020-02-22 14:41:01 +03:00
if _, ok := db.Get("rows"); ok {
2020-03-09 08:10:48 +03:00
db.Statement.Dest, db.Error = db.Statement.ConnPool.QueryContext(db.Statement.Context, db.Statement.SQL.String(), db.Statement.Vars...)
2020-02-22 14:41:01 +03:00
} else {
2020-03-09 08:10:48 +03:00
db.Statement.Dest = db.Statement.ConnPool.QueryRowContext(db.Statement.Context, db.Statement.SQL.String(), db.Statement.Vars...)
2020-02-22 14:41:01 +03:00
}
}