From d86dd8cdb9dd4d438e749e9c967a00de6aa2d704 Mon Sep 17 00:00:00 2001 From: chenquan Date: Sun, 11 Sep 2022 22:01:19 +0800 Subject: [PATCH] fix: fix prepare context --- stmt.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/stmt.go b/stmt.go index ab77ca2..ffc55ea 100644 --- a/stmt.go +++ b/stmt.go @@ -14,7 +14,12 @@ var ( type prepareContextKey struct{} func PrepareContextFromContext(ctx context.Context) context.Context { - return ctx.Value(prepareContextKey{}).(context.Context) + value := ctx.Value(prepareContextKey{}) + if value != nil { + return value.(context.Context) + } + + return nil } type stmt struct {