forked from mirror/gorm
Return RecordNotFound error when no record found for slice
This commit is contained in:
parent
0cba662be0
commit
319af32c78
|
@ -61,7 +61,7 @@ func Query(scope *Scope) {
|
|||
}
|
||||
}
|
||||
|
||||
if !anyRecordFound && !isSlice {
|
||||
if !anyRecordFound {
|
||||
scope.Err(RecordNotFound)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue