Merge branch 'master' into master
This commit is contained in:
commit
22568ea136
|
@ -363,7 +363,7 @@ return session.Commit()
|
||||||
* Or you can use `Transaction` to replace above codes.
|
* Or you can use `Transaction` to replace above codes.
|
||||||
|
|
||||||
```Go
|
```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()}
|
user1 := Userinfo{Username: "xiaoxiao", Departname: "dev", Alias: "lunny", Created: time.Now()}
|
||||||
if _, err := session.Insert(&user1); err != nil {
|
if _, err := session.Insert(&user1); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
|
@ -42,6 +42,8 @@ func (session *Session) Exist(bean ...interface{}) (bool, error) {
|
||||||
|
|
||||||
if session.engine.dialect.DBType() == core.MSSQL {
|
if session.engine.dialect.DBType() == core.MSSQL {
|
||||||
sqlStr = fmt.Sprintf("SELECT TOP 1 * FROM %s WHERE %s", tableName, condSQL)
|
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 {
|
} else {
|
||||||
sqlStr = fmt.Sprintf("SELECT * FROM %s WHERE %s LIMIT 1", tableName, condSQL)
|
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 {
|
} else {
|
||||||
if session.engine.dialect.DBType() == core.MSSQL {
|
if session.engine.dialect.DBType() == core.MSSQL {
|
||||||
sqlStr = fmt.Sprintf("SELECT TOP 1 * FROM %s", tableName)
|
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 {
|
} else {
|
||||||
sqlStr = fmt.Sprintf("SELECT * FROM %s LIMIT 1", tableName)
|
sqlStr = fmt.Sprintf("SELECT * FROM %s LIMIT 1", tableName)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue