From d195040cb941db63e82ba4f54a6c194bab0f614f Mon Sep 17 00:00:00 2001 From: finelog Date: Thu, 31 Mar 2022 17:20:29 +0800 Subject: [PATCH 1/2] fix session context overwrite when logSessionId not set (#2115) ref pr https://gitea.com/xorm/xorm/pulls/2053 i think the previous fix has some issue for example, i'm using session like this: ```go // logSessionID == false engine := NewEngine() // use ctx.SessionId to distinguish uniq request id cxt := context.WithValue(parent, log.SessionIDKey, "some unique request id") session := engine.NewSession().Context(ctx) ``` however, with pr 2053, `session.Context` can't get SessionId from ctx. this pr fix abrove issue, overwrite `session.Context()` only when `engine.logSessionID == true` please check it out,thanks! Co-authored-by: finelog Co-authored-by: Lunny Xiao Reviewed-on: https://gitea.com/xorm/xorm/pulls/2115 Co-authored-by: finelog Co-committed-by: finelog --- 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)) From b3f9c53d8abeb8870c579312d1a28293813e92fd Mon Sep 17 00:00:00 2001 From: getsu Date: Thu, 31 Mar 2022 23:57:40 +0800 Subject: [PATCH 2/2] =?UTF-8?q?oracle=E6=95=B0=E6=8D=AE=E5=BA=93=E4=B8=8D?= =?UTF-8?q?=E5=86=8D=E6=8B=BC=E6=8E=A5AS=20(#2109)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复 #2108 Co-authored-by: chendy Co-authored-by: Lunny Xiao Reviewed-on: https://gitea.com/xorm/xorm/pulls/2109 Co-authored-by: getsu Co-committed-by: getsu --- dialects/table_name.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/dialects/table_name.go b/dialects/table_name.go index 48b44de2..8a0baeac 100644 --- a/dialects/table_name.go +++ b/dialects/table_name.go @@ -11,6 +11,7 @@ import ( "xorm.io/xorm/internal/utils" "xorm.io/xorm/names" + "xorm.io/xorm/schemas" ) // TableNameWithSchema will add schema prefix on table name if possible @@ -29,6 +30,9 @@ func TableNameNoSchema(dialect Dialect, mapper names.Mapper, tableName interface switch tt := tableName.(type) { case []string: if len(tt) > 1 { + if dialect.URI().DBType == schemas.ORACLE { + return fmt.Sprintf("%v %v", quote(tt[0]), quote(tt[1])) + } return fmt.Sprintf("%v AS %v", quote(tt[0]), quote(tt[1])) } else if len(tt) == 1 { return quote(tt[0]) @@ -54,6 +58,9 @@ func TableNameNoSchema(dialect Dialect, mapper names.Mapper, tableName interface } } if l > 1 { + if dialect.URI().DBType == schemas.ORACLE { + return fmt.Sprintf("%v %v", quote(table), quote(fmt.Sprintf("%v", tt[1]))) + } return fmt.Sprintf("%v AS %v", quote(table), quote(fmt.Sprintf("%v", tt[1]))) } else if l == 1 { return quote(table)