Don't raise error if no record found when find all

This commit is contained in:
Jinzhu 2014-12-19 11:46:48 +08:00
parent 6f2e92e136
commit 0219fb1cc0
2 changed files with 3 additions and 3 deletions

View File

@ -76,7 +76,7 @@ func Query(scope *Scope) {
} }
} }
if !anyRecordFound { if !anyRecordFound && !isSlice {
scope.Err(RecordNotFound) scope.Err(RecordNotFound)
} }
} }

View File

@ -146,8 +146,8 @@ func TestSearchWithPlainSQL(t *testing.T) {
t.Errorf("Should found 1 users, but got %v", len(users)) t.Errorf("Should found 1 users, but got %v", len(users))
} }
if !DB.Where("name = ?", "none existing").Find(&[]User{}).RecordNotFound() { if DB.Where("name = ?", "none existing").Find(&[]User{}).RecordNotFound() {
t.Errorf("Should get RecordNotFound error when looking for none existing records") t.Errorf("Should not get RecordNotFound error when looking for none existing records")
} }
} }