fix to add session.statement.IsForUpdate check in Session.queryRows()

# Issue
The 'for-update' query is executed to slave DB node.  


# Example

```go
s := engineGroup.NewSession(); // create session from EngineGroup.
...

s.ForUpdate();

type User struct { ... };
has, err := s.Get(&user); // executed to slave DB node.
...
```
This commit is contained in:
rennnosuke 2021-10-28 16:38:22 +08:00
parent 40a135948b
commit e03ecdfeee
1 changed files with 1 additions and 1 deletions

View File

@ -33,7 +33,7 @@ func (session *Session) queryRows(sqlStr string, args ...interface{}) (*core.Row
if session.isAutoCommit {
var db *core.DB
if session.sessionType == groupSession && strings.EqualFold(sqlStr[:6], "select") {
if session.sessionType == groupSession && strings.EqualFold(sqlStr[:6], "select") && !session.statement.IsForUpdate {
db = session.engine.engineGroup.Slave().DB()
} else {
db = session.DB()