mirror of https://github.com/go-gorm/gorm.git
Don't raise error if no record found when find all
This commit is contained in:
parent
6f2e92e136
commit
0219fb1cc0
|
@ -76,7 +76,7 @@ func Query(scope *Scope) {
|
|||
}
|
||||
}
|
||||
|
||||
if !anyRecordFound {
|
||||
if !anyRecordFound && !isSlice {
|
||||
scope.Err(RecordNotFound)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -146,8 +146,8 @@ func TestSearchWithPlainSQL(t *testing.T) {
|
|||
t.Errorf("Should found 1 users, but got %v", len(users))
|
||||
}
|
||||
|
||||
if !DB.Where("name = ?", "none existing").Find(&[]User{}).RecordNotFound() {
|
||||
t.Errorf("Should get RecordNotFound error when looking for none existing records")
|
||||
if DB.Where("name = ?", "none existing").Find(&[]User{}).RecordNotFound() {
|
||||
t.Errorf("Should not get RecordNotFound error when looking for none existing records")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue