From 28600a89ea7c4e0c5501ba54be4737a094aa244a Mon Sep 17 00:00:00 2001 From: finelog Date: Tue, 22 Feb 2022 17:31:16 +0800 Subject: [PATCH] fix session context overwrite when logSessionId not set --- session.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/session.go b/session.go index 21bbe6e1..3fc53e23 100644 --- a/session.go +++ b/session.go @@ -757,7 +757,7 @@ func (session *Session) incrVersionFieldValue(fieldValue *reflect.Value) { // Context sets the context on this session func (session *Session) Context(ctx context.Context) *Session { - if session.ctx != nil { + if session.engine.logSessionID && session.ctx != nil { ctx = context.WithValue(ctx, log.SessionIDKey, session.ctx.Value(log.SessionIDKey)) ctx = context.WithValue(ctx, log.SessionKey, session.ctx.Value(log.SessionKey)) ctx = context.WithValue(ctx, log.SessionShowSQLKey, session.ctx.Value(log.SessionShowSQLKey))