mirror of
https://github.com/astaxie/beego.git
synced 2024-12-23 06:10:51 +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:
commit
8241f219fd
@ -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.
|
||||
|
@ -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))
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user