diff --git a/query_base.go b/query_base.go index 4b3545d0d..7c7bf681a 100644 --- a/query_base.go +++ b/query_base.go @@ -588,7 +588,7 @@ func (q *baseQuery) exec( ) (sql.Result, error) { ctx, event := q.db.beforeQuery(ctx, iquery, query, nil, query, q.model) res, err := q.conn.ExecContext(ctx, query) - q.db.afterQuery(ctx, event, nil, err) + q.db.afterQuery(ctx, event, res, err) return res, err } diff --git a/query_select.go b/query_select.go index cd494a369..c0e145110 100644 --- a/query_select.go +++ b/query_select.go @@ -813,7 +813,11 @@ func (q *SelectQuery) Rows(ctx context.Context) (*sql.Rows, error) { } query := internal.String(queryBytes) - return q.conn.QueryContext(ctx, query) + + ctx, event := q.db.beforeQuery(ctx, q, query, nil, query, q.model) + rows, err := q.conn.QueryContext(ctx, query) + q.db.afterQuery(ctx, event, nil, err) + return rows, err } func (q *SelectQuery) Exec(ctx context.Context, dest ...interface{}) (res sql.Result, err error) {