How do I know if update_all or delete_all are successful or not?

Since Ecto 3.0, the return values of Repo.update_all and Repo.delete_all have changed from

{integer(), nil | [term()]} | no_return()

to

{integer(), nil | [term()]}.

I’m confused. Does it mean the two functions no longer raise and the function calls always succeed? If not, how do I know when errors occur?

No, it just means that no_return has been removed from the annotation, as it is implied for all functions anyway. From a dialyzer point if view it makes only sense for functions that always raise or do recurse infinitely.

Do you mean they still raise when errors occur?

What should it do otherwise?

It does seem like basically none of the repo functions have no_return() anymore, which does seem particularly weird for functions like Repo.one! which will very explicitly raise if nothing is found. All of them will raise if passed an invalid schema.

The functions definitely still raise, I’m not sure why that part of the typespec was removed.

2 Likes

That’s because no_return is always implied. A function can always fail. Since no_return is a bottom type, no no_return is only necessary when it is the only return type. :slight_smile:

5 Likes

Makes sense, thanks!