elixir-ecto / db_connection

Database connection behaviour
http://hexdocs.pm/db_connection/DBConnection.html
306 stars 113 forks source link

Prepare and retry some encode failures #123

Closed fishcakez closed 6 years ago

fishcakez commented 6 years ago

If we have a prepared query struct with stale types, and we try execute that query with parameters for the new types the encode will fail without hitting the database. To handle this gracefully we should rescue DBConnection.EncodeErrorexceptions (or similarly unique exception) on encode calls to the query protocol. If it is an execute call we should go to prepare_execute to prepare a new version of the query and try to encode again. Similarly for declare/prepare_declare. For other functions we rescue EncodeError and return it in error tuple.