1
0
mirror of https://github.com/astaxie/beego.git synced 2025-07-07 02:10:17 +00:00

remove orm one function thorw ErrMultiRows error

This commit is contained in:
maxin[马鑫]
2016-04-13 10:36:12 +08:00
parent 9679f5e22a
commit 81c6c898cf
2 changed files with 8 additions and 7 deletions

View File

@ -969,13 +969,19 @@ func TestOne(t *testing.T) {
var user User
qs := dORM.QueryTable("user")
err := qs.One(&user)
throwFail(t, AssertIs(err, ErrMultiRows))
throwFail(t, err)
throwFail(t, AssertIs(user.UserName, "slene"))
user = User{}
err = qs.OrderBy("Id").Limit(1).One(&user)
throwFailNow(t, err)
throwFail(t, AssertIs(user.UserName, "slene"))
user = User{}
err = qs.OrderBy("-Id").Limit(100).One(&user)
throwFailNow(t, err)
throwFail(t, AssertIs(user.UserName, "nobody"))
err = qs.Filter("user_name", "nothing").One(&user)
throwFail(t, AssertIs(err, ErrNoRows))