Fix assertion error on delete with records that have hasMany relationships