elixir-ecto / db_connection

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

Use prepare/execute for queries and remove handle_query #3

Closed fishcakez closed 8 years ago

fishcakez commented 8 years ago

A query should be carried out as a prepare and a execute so that parameter encoding does not have to be done inside handle_query where an error will crash the connection. It also means adapters do not have to handle the prepare/encode/execute logic themselves.

However this leads to an issue where un-named queries won't be closed after a query without adding a round trip to explicitly close with handle_close. One way to solve this is to introduce a handle_execute_close and execute_close that allows an adapter to handle the execute and close in an efficient manor. The default implementation provided by __using__ would call handle_execute and handle_close.

josevalim commented 8 years ago

:heart: :green_heart: :blue_heart: :yellow_heart: :purple_heart: