row.go 560 B

12345678910111213141516171819202122
  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.Get("rows"); ok && isRows.(bool) {
  10. db.Statement.Settings.Delete("rows")
  11. db.Statement.Dest, db.Error = db.Statement.ConnPool.QueryContext(db.Statement.Context, db.Statement.SQL.String(), db.Statement.Vars...)
  12. } else {
  13. db.Statement.Dest = db.Statement.ConnPool.QueryRowContext(db.Statement.Context, db.Statement.SQL.String(), db.Statement.Vars...)
  14. }
  15. db.RowsAffected = -1
  16. }
  17. }
  18. }