From 319af32c7898d73194c1357a8e854660b1eabbda Mon Sep 17 00:00:00 2001 From: Jinzhu Date: Thu, 5 Jun 2014 17:15:25 +0800 Subject: [PATCH] Return RecordNotFound error when no record found for slice --- callback_query.go | 2 +- main_test.go | 8 ++------ 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/callback_query.go b/callback_query.go index b59a60a5..113382e1 100644 --- a/callback_query.go +++ b/callback_query.go @@ -61,7 +61,7 @@ func Query(scope *Scope) { } } - if !anyRecordFound && !isSlice { + if !anyRecordFound { scope.Err(RecordNotFound) } } diff --git a/main_test.go b/main_test.go index 78e79f23..7310dd40 100644 --- a/main_test.go +++ b/main_test.go @@ -419,12 +419,8 @@ func TestWhere(t *testing.T) { } var users []User - if db.Where("name = ?", "none-noexisting").Find(&users).Error != nil { - t.Errorf("Shouldn't return error when looking for none existing records with find") - } - - if len(users) != 0 { - t.Errorf("Users should be empty") + if !db.Where("name = ?", "none-noexisting").Find(&users).RecordNotFound() { + t.Errorf("Should get RecordNotFound error when looking for none existing records") } }