Skip to content

Commit

Permalink
Merge pull request #4548 from livelyRyan/livelyRyan-patch-1
Browse files Browse the repository at this point in the history
将操作数据库的错误进行返回
  • Loading branch information
flycash committed Mar 31, 2021
2 parents 1c1f67d + 77ae327 commit ec707d0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -27,6 +27,7 @@
- fix: code quality issues [4513](https://github.com/beego/beego/pull/4513)
- Optimize maligned structs to reduce memory foot-print [4525](https://github.com/beego/beego/pull/4525)
- Feat: add token bucket ratelimit filter [4508](https://github.com/beego/beego/pull/4508)
- Improve: Avoid ignoring mistakes that need attention [4548](https://github.com/beego/beego/pull/4548)



Expand Down
7 changes: 6 additions & 1 deletion server/web/session/mysql/sess_mysql.go
Expand Up @@ -150,6 +150,8 @@ func (mp *Provider) SessionRead(ctx context.Context, sid string) (session.Store,
if err == sql.ErrNoRows {
c.Exec("insert into "+TableName+"(`session_key`,`session_data`,`session_expiry`) values(?,?,?)",
sid, "", time.Now().Unix())
} else if err != nil {
return nil, err
}
var kv map[interface{}]interface{}
if len(sessiondata) == 0 {
Expand Down Expand Up @@ -189,7 +191,10 @@ func (mp *Provider) SessionRegenerate(ctx context.Context, oldsid, sid string) (
if err == sql.ErrNoRows {
c.Exec("insert into "+TableName+"(`session_key`,`session_data`,`session_expiry`) values(?,?,?)", oldsid, "", time.Now().Unix())
}
c.Exec("update "+TableName+" set `session_key`=? where session_key=?", sid, oldsid)
_, err = c.Exec("update "+TableName+" set `session_key`=? where session_key=?", sid, oldsid)
if err != nil {
return nil, err
}
var kv map[interface{}]interface{}
if len(sessiondata) == 0 {
kv = make(map[interface{}]interface{})
Expand Down

0 comments on commit ec707d0

Please sign in to comment.