row.go 527 B

123456789101112131415161718192021
  1. package callbacks
  2. import (
  3. "gorm.io/gorm"
  4. )
  5. func RowQuery(db *gorm.DB) {
  6. if db.Error == nil {
  7. BuildQuerySQL(db)
  8. if !db.DryRun {
  9. if isRows, ok := db.InstanceGet("rows"); ok && isRows.(bool) {
  10. db.Statement.Dest, db.Error = db.Statement.ConnPool.QueryContext(db.Statement.Context, db.Statement.SQL.String(), db.Statement.Vars...)
  11. } else {
  12. db.Statement.Dest = db.Statement.ConnPool.QueryRowContext(db.Statement.Context, db.Statement.SQL.String(), db.Statement.Vars...)
  13. }
  14. db.RowsAffected = -1
  15. }
  16. }
  17. }