From 1bd3fb7a333fd72a7c93d387a8957fbbecb52e1c Mon Sep 17 00:00:00 2001 From: Hu Risheng Date: Fri, 3 Aug 2018 13:35:48 +0800 Subject: [PATCH 1/2] =?UTF-8?q?Revert=20"send=20ErrNoRows=20if=20the=20que?= =?UTF-8?q?ry=20returns=20zero=20rows=20...=20in=20method=20orm=5Fquery?= =?UTF-8?q?=E2=80=A6"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- orm/orm_queryset.go | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/orm/orm_queryset.go b/orm/orm_queryset.go index 8b5d6fd2..4bab1d98 100644 --- a/orm/orm_queryset.go +++ b/orm/orm_queryset.go @@ -198,11 +198,7 @@ func (o *querySet) PrepareInsert() (Inserter, error) { // query all data and map to containers. // cols means the columns when querying. 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) - if num == 0 { - return 0, ErrNoRows - } - return num, err + return o.orm.alias.DbBaser.ReadBatch(o.orm.db, o, o.mi, o.cond, container, o.orm.alias.TZ, cols) } // query one row data and map to containers. From dea45a3d6c711789d83ade3eeee4166fc42f1112 Mon Sep 17 00:00:00 2001 From: hurisheng Date: Tue, 7 Aug 2018 16:36:27 +0800 Subject: [PATCH 2/2] fix TestAll() --- orm/orm_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/orm/orm_test.go b/orm/orm_test.go index cdb2fe3f..ceb814ff 100644 --- a/orm/orm_test.go +++ b/orm/orm_test.go @@ -1011,13 +1011,13 @@ func TestAll(t *testing.T) { qs = dORM.QueryTable("user") num, err = qs.Filter("user_name", "nothing").All(&users) - throwFailNow(t, AssertIs(err, ErrNoRows)) + throwFailNow(t, err) throwFailNow(t, AssertIs(num, 0)) var users3 []*User qs = dORM.QueryTable("user") 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(users3 == nil, false)) }