未验证 提交 8241f219 编写于 作者: A astaxie 提交者: GitHub

Merge pull request #3278 from hurisheng/revert-3247-develop

Revert "send ErrNoRows if the query returns zero rows ... in method orm_query…"
...@@ -198,11 +198,7 @@ func (o *querySet) PrepareInsert() (Inserter, error) { ...@@ -198,11 +198,7 @@ func (o *querySet) PrepareInsert() (Inserter, error) {
// query all data and map to containers. // query all data and map to containers.
// cols means the columns when querying. // cols means the columns when querying.
func (o *querySet) All(container interface{}, cols ...string) (int64, error) { func (o *querySet) All(container interface{}, cols ...string) (int64, error) {
num, err := o.orm.alias.DbBaser.ReadBatch(o.orm.db, o, o.mi, o.cond, container, o.orm.alias.TZ, cols) return o.orm.alias.DbBaser.ReadBatch(o.orm.db, o, o.mi, o.cond, container, o.orm.alias.TZ, cols)
if num == 0 {
return 0, ErrNoRows
}
return num, err
} }
// query one row data and map to containers. // query one row data and map to containers.
......
...@@ -1011,13 +1011,13 @@ func TestAll(t *testing.T) { ...@@ -1011,13 +1011,13 @@ func TestAll(t *testing.T) {
qs = dORM.QueryTable("user") qs = dORM.QueryTable("user")
num, err = qs.Filter("user_name", "nothing").All(&users) num, err = qs.Filter("user_name", "nothing").All(&users)
throwFailNow(t, AssertIs(err, ErrNoRows)) throwFailNow(t, err)
throwFailNow(t, AssertIs(num, 0)) throwFailNow(t, AssertIs(num, 0))
var users3 []*User var users3 []*User
qs = dORM.QueryTable("user") qs = dORM.QueryTable("user")
num, err = qs.Filter("user_name", "nothing").All(&users3) num, err = qs.Filter("user_name", "nothing").All(&users3)
throwFailNow(t, AssertIs(err, ErrNoRows)) throwFailNow(t, err)
throwFailNow(t, AssertIs(num, 0)) throwFailNow(t, AssertIs(num, 0))
throwFailNow(t, AssertIs(users3 == nil, false)) throwFailNow(t, AssertIs(users3 == nil, false))
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册