Skip to content

Commit

Permalink
fix: run hooks on Rows (#892)
Browse files Browse the repository at this point in the history
  • Loading branch information
vmihailenco authored Sep 10, 2023
1 parent f2256f1 commit f652b3d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion query_base.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
6 changes: 5 additions & 1 deletion query_select.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit f652b3d

Please sign in to comment.