Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

session.QueryRows中方法查询失败后,未检查返回的core.Rows是否为nil,直接rows.close,导致panic #84

Open
GitHubScience opened this issue Nov 21, 2020 · 2 comments

Comments

@GitHubScience
Copy link

session.queryRows方法查询失败后,未检查返回的core.Rows是否为nil,直接rows.close,导致panic,致使不能正常返回预期的错误信息
image

@GitHubScience GitHubScience changed the title session.queryRows方法查询失败后,发生panic session.queryRows方法查询失败后,未检查返回的core.Rows是否为nil,直接rows.close,导致panic Nov 21, 2020
@GitHubScience GitHubScience changed the title session.queryRows方法查询失败后,未检查返回的core.Rows是否为nil,直接rows.close,导致panic session.QueryRows方法查询失败后,未检查返回的core.Rows是否为nil,直接rows.close,导致panic Nov 21, 2020
@GitHubScience GitHubScience changed the title session.QueryRows方法查询失败后,未检查返回的core.Rows是否为nil,直接rows.close,导致panic session.QueryRows中方法查询失败后,未检查返回的core.Rows是否为nil,直接rows.close,导致panic Nov 21, 2020
@xormplus
Copy link
Owner

能否提供以下你的具体调用代码和数据样例,谢谢

@GitHubScience
Copy link
Author

代码示例如下:
func TestQueryRows(t *testing.T) {
db, err := xorm.NewEngine("mysql", "")
session := db.NewSession()
var sqlOrArgs []interface{}
sqlOrArgs = append(sqlOrArgs," select * from user where id = ?",1)

//调用代码后,错误信息没有返回,内部发生 panic
rows, err := session.QueryRows(sqlOrArgs...)
if err != nil {
	fmt.Println("err : ",err)
	return
}
defer rows.Close()

}
image
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants