From 1888335b6e73bb7bd8b549741b4c2a91d590c931 Mon Sep 17 00:00:00 2001 From: Jinzhu Date: Wed, 28 Jan 2015 11:16:29 +0800 Subject: [PATCH] Add RowsAffected for query --- callback_query.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/callback_query.go b/callback_query.go index 4cdebedb..02824366 100644 --- a/callback_query.go +++ b/callback_query.go @@ -41,14 +41,18 @@ func Query(scope *Scope) { if !scope.HasError() { rows, err := scope.DB().Query(scope.Sql, scope.SqlVars...) + scope.db.RowsAffected = 0 if scope.Err(err) != nil { return } - defer rows.Close() columns, _ := rows.Columns() + + defer rows.Close() for rows.Next() { + scope.db.RowsAffected += 1 + anyRecordFound = true elem := dest if isSlice {