Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to DBConnection 2.0 #235

Merged
merged 19 commits into from
Sep 24, 2018
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 16 additions & 12 deletions lib/mariaex.ex
Original file line number Diff line number Diff line change
Expand Up @@ -240,10 +240,12 @@ defmodule Mariaex do
{:ok, Mariaex.Result.t} | {:error, Mariaex.Error.t}
def execute(conn, %Query{} = query, params, opts \\ []) do
case DBConnection.execute(conn, query, params, defaults(opts)) do
{:error, %ArgumentError{} = err} ->
{:ok, _} = ok ->
ok
{:error, %Mariaex.Error{}} = error ->
error
{:error, err} ->
raise err
other ->
other
end
end

Expand Down Expand Up @@ -289,10 +291,10 @@ defmodule Mariaex do
case DBConnection.close(conn, query, defaults(opts)) do
{:ok, _} ->
:ok
{:error, %ArgumentError{} = err} ->
{:error, %Mariaex.Error{}} = error ->
error
{:error, err} ->
raise err
other ->
other
end
end

Expand Down Expand Up @@ -421,19 +423,21 @@ defmodule Mariaex do
case DBConnection.prepare_execute(conn, query, params, defaults(opts)) do
{:ok, _, result} ->
{:ok, result}
{:error, %ArgumentError{} = err} ->
raise err
{:error, _} = error ->
{:error, %Mariaex.Error{}} = error ->
error
{:error, err} ->
raise err
end
end

defp prepare_binary(conn, query, opts) do
case DBConnection.prepare(conn, query, defaults(opts)) do
{:error, %ArgumentError{} = err} ->
{:ok, _} = ok ->
ok
{:error, %Mariaex.Error{}} = error ->
error
{:error, err} ->
raise err
other ->
other
end
end

Expand Down
Loading