1
0
mirror of https://github.com/astaxie/beego.git synced 2024-06-25 06:34:13 +00:00

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

Revert "send ErrNoRows if the query returns zero rows ... in method orm_query…"
This commit is contained in:
astaxie 2018-08-09 17:05:01 +08:00 committed by GitHub
commit 8241f219fd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 7 deletions

View File

@ -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.

View File

@ -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))
}