fix session context overwrite when logSessionId not set

This commit is contained in:
finelog 2022-02-22 17:31:16 +08:00
parent 3180c418c2
commit 28600a89ea
1 changed files with 1 additions and 1 deletions

View File

@ -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))