From ee64beb73ba5733e5427caeef015e1fcde965860 Mon Sep 17 00:00:00 2001 From: button-chen <727690080@qq.com> Date: Wed, 13 Feb 2019 12:37:14 +0800 Subject: [PATCH 1/2] =?UTF-8?q?fix=20bug=20in=20oracle=EF=BC=9A=20engine.T?= =?UTF-8?q?able(tablename).Exist()=20(#1227)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- session_exist.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/session_exist.go b/session_exist.go index 5d3969f9..6aa154aa 100644 --- a/session_exist.go +++ b/session_exist.go @@ -42,6 +42,8 @@ func (session *Session) Exist(bean ...interface{}) (bool, error) { if session.engine.dialect.DBType() == core.MSSQL { sqlStr = fmt.Sprintf("SELECT TOP 1 * FROM %s WHERE %s", tableName, condSQL) + } else if session.engine.dialect.DBType() == core.ORACLE { + sqlStr = fmt.Sprintf("SELECT * FROM %s WHERE (%s) AND ROWNUM=1", tableName, condSQL) } else { sqlStr = fmt.Sprintf("SELECT * FROM %s WHERE %s LIMIT 1", tableName, condSQL) } @@ -49,6 +51,8 @@ func (session *Session) Exist(bean ...interface{}) (bool, error) { } else { if session.engine.dialect.DBType() == core.MSSQL { sqlStr = fmt.Sprintf("SELECT TOP 1 * FROM %s", tableName) + } else if session.engine.dialect.DBType() == core.ORACLE { + sqlStr = fmt.Sprintf("SELECT * FROM %s WHERE ROWNUM=1", tableName) } else { sqlStr = fmt.Sprintf("SELECT * FROM %s LIMIT 1", tableName) } From e410f04aaf2db78083222488e35a0cff3b0ca2f1 Mon Sep 17 00:00:00 2001 From: faith Date: Wed, 13 Feb 2019 14:43:01 +0800 Subject: [PATCH 2/2] Update README.md (#1228) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit sess 修改为 session --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 6a57606e..5c64e776 100644 --- a/README.md +++ b/README.md @@ -363,7 +363,7 @@ return session.Commit() * Or you can use `Transaction` to replace above codes. ```Go -res, err := engine.Transaction(func(sess *xorm.Session) (interface{}, error) { +res, err := engine.Transaction(func(session *xorm.Session) (interface{}, error) { user1 := Userinfo{Username: "xiaoxiao", Departname: "dev", Alias: "lunny", Created: time.Now()} if _, err := session.Insert(&user1); err != nil { return nil, err @@ -493,4 +493,4 @@ Support this project by becoming a sponsor. Your logo will show up here with a l ## LICENSE -BSD License [http://creativecommons.org/licenses/BSD/](http://creativecommons.org/licenses/BSD/) \ No newline at end of file +BSD License [http://creativecommons.org/licenses/BSD/](http://creativecommons.org/licenses/BSD/)