From 55f95db028ed1a4055362c00dbea5774156336b5 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Mon, 13 Sep 2021 15:19:59 +0800 Subject: [PATCH] Fix bug (#2046) Reviewed-on: https://gitea.com/xorm/xorm/pulls/2046 Co-authored-by: Lunny Xiao Co-committed-by: Lunny Xiao --- rows.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/rows.go b/rows.go index 8e7cc075..cdabe023 100644 --- a/rows.go +++ b/rows.go @@ -84,12 +84,18 @@ func newRows(session *Session, bean interface{}) (*Rows, error) { // Next move cursor to next record, return false if end has reached func (rows *Rows) Next() bool { - return rows.rows.Next() + if rows.rows != nil { + return rows.rows.Next() + } + return false } // Err returns the error, if any, that was encountered during iteration. Err may be called after an explicit or implicit Close. func (rows *Rows) Err() error { - return rows.rows.Err() + if rows.rows != nil { + return rows.rows.Err() + } + return nil } // Scan row record to bean properties