Skip to content

Commit

Permalink
Bug/missing AllowRoot panics no context methods (#227)
Browse files Browse the repository at this point in the history
* Check that methodTracer is not nil before adding it as middleware

* Check for when methodTracer is == nil, not != nil
  • Loading branch information
nilsolofsson authored Aug 29, 2023
1 parent 3e506ca commit df931df
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions query.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,13 @@ func queryWrapRows(t methodTracer, traceLastInsertID bool, traceRowsAffected boo
func makeQueryerContextMiddlewares(r methodRecorder, t methodTracer, cfg queryConfig) []queryContextFuncMiddleware {
middlewares := make([]queryContextFuncMiddleware, 0, 3)

middlewares = append(middlewares,
queryStats(r, cfg.metricMethod),
queryTrace(t, cfg.traceQuery, cfg.traceMethod),
)
middlewares = append(middlewares, queryStats(r, cfg.metricMethod))

if t == nil {
return middlewares
}

middlewares = append(middlewares, queryTrace(t, cfg.traceQuery, cfg.traceMethod))

if cfg.traceRowsNext || cfg.traceRowsClose {
middlewares = append(middlewares, queryWrapRows(t, cfg.traceRowsNext, cfg.traceRowsClose))
Expand Down

0 comments on commit df931df

Please sign in to comment.