this method may cause caller does not get all the rows, but the truth is due to error occurred, and there's no way for caller to detect error #1992

Closed
opened 2021-07-15 09:47:42 +00:00 by heron-sense · 2 comments

779a74ccff/session_find.go (L252)

In the source code from golang, any error during calling the Next method is depressed, after calling Next if got false, should call rows.Err() to detect if error orrurred.

// Every call to Scan, even the first one, must be preceded by a call to Next.
func (rs *Rows) Next() bool {
var doClose, ok bool
withLock(rs.closemu.RLocker(), func() {
doClose, ok = rs.nextLocked()
})
if doClose {
rs.Close()
}
return ok
}

https://gitea.com/xorm/xorm/src/commit/779a74ccff7e50341c48eb59d7fd77330a74d5b5/session_find.go#L252 In the source code from golang, any error during calling the Next method is depressed, after calling Next if got false, should call rows.Err() to detect if error orrurred. // Every call to Scan, even the first one, must be preceded by a call to Next. func (rs *Rows) Next() bool { var doClose, ok bool withLock(rs.closemu.RLocker(), func() { doClose, ok = rs.nextLocked() }) if doClose { rs.Close() } return ok }
heron-sense changed title from 这里可能会因为连接被server端断开,导致并未读取所有的行 to this method may cause caller does not get all the rows, but the truth is due to error occurred, and there's no way for caller to detect error 2021-07-15 10:05:54 +00:00
Owner

Hi, could you send a PR to resolve the problem?

Hi, could you send a PR to resolve the problem?
lunny added the
kind
bug
label 2021-07-15 15:10:51 +00:00
Author

Thanks so much for your reply, I've just initialized a PR for this issue, by any chance help to check.

Thanks so much for your reply, I've just initialized a PR for this issue, by any chance help to check.
lunny added this to the 1.2.0 milestone 2021-07-19 05:04:05 +00:00
lunny closed this issue 2021-07-19 05:43:54 +00:00
lunny closed this issue 2021-07-19 05:43:54 +00:00
Sign in to join this conversation.
No Milestone
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: xorm/xorm#1992
No description provided.