-
Notifications
You must be signed in to change notification settings - Fork 89
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
Conversation
test/start_test.exs
Outdated
assert capture_log(fn -> | ||
{:ok, pid} = Mariaex.start_link([username: "non_existing", database: "mariaex_test"] ++ opts) | ||
assert_receive {:EXIT, ^pid, :killed}, 5000 | ||
end) =~ "** (Mariaex.Error) (1045): Access denied for user 'non_existing'@'localhost'" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should check up to and including the @
I guess. Unsure what happens on other languages though. Ideally we would have similar style to postgrex where every error code has a matching atom.
test/transaction_test.exs
Outdated
assert query("SELECT 42", []) == [[42]] | ||
end | ||
|
||
test "can not begin, commit or rollback savepoint transaction if not begun", context do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should mention savepoint in this name as its confusing to say can not begin if mnot not begun without that context.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wait, we do mention savepoint. Or should we not mention it? Btw, you wrote this. :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right, this test is wonderful ;)
{:ok, {result, nil}, clean_state(s, flags)} | ||
end | ||
|
||
defp clean_state(state, flags) do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to test that we always call this function after a query finishes.
Need some time to think about that this TODO means. Likely on the first |
This looks good to merge if we open issues for the TODO items so we can unblock ecto dev. |
lib/mariaex.ex
Outdated
@@ -237,16 +236,9 @@ defmodule Mariaex do | |||
Mariaex.execute(conn, query, ["%my%"]) | |||
""" | |||
@spec execute(conn, Mariaex.Query.t, list, Keyword.t) :: | |||
{:ok, Mariaex.Result.t} | {:error, Mariaex.Error.t} | |||
{:ok, Mariaex.Query.t, Mariaex.Result.t} | {:error, Mariaex.Error.t} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this can now return other exceptions in the error case?
lib/mariaex.ex
Outdated
{:error, err} -> | ||
raise err | ||
err |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I dont think this right, don't we want to return the error tuple?
lib/mariaex.ex
Outdated
{:error, err} -> | ||
raise err | ||
err |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems I reviewed only one commit before and you fixed all the comments in later ones. If we have Exception.t as return make sure docs have that everywhere, I left comment in one place.
lib/mariaex.ex
Outdated
@@ -205,6 +209,58 @@ defmodule Mariaex do | |||
end | |||
end | |||
|
|||
@doc """ | |||
Prepares and executes a query and returns the result as | |||
`{:ok, %Mariaex.Query{}, %Mariaex.Result{}}` or `{:error, %Mariaex.Error{}}` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It can be any exception?
Thank you ❤️ |
Includes #196 and #234. Note DBConnection 2.0 has not been released yet. There is also some work pending:
/cc @wojtekmach @fishcakez