Doing a refactor I recently ran into this error when writing a regression test .
(Ecto.Query.CastError) deps/ecto/lib/ecto/repo/queryable.ex:373: value `"dogs"` in `where` cannot be cast to type :id in query:
I realize that for a long time I’ve been making the false assumption that if I pass a nonsense string as a parameter for the primary to
Repo.get(SchemaName, string_input), that the default Ecto primary key casting queued by the query build would return an error/nil result when it couldn’t parse the string to an interger, rathan that raising the CastError.
My question is not how to handle this, I can explicitly cast and pre-validated the input just fine, but rather what pattern people are using for this in a routine situation of accepting a web param for id and doing a lookup. Is there some sort of option I’m missing for Ecto or a reason to do explicit interger casting here that I’m not seeing?