-
Notifications
You must be signed in to change notification settings - Fork 67
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
Handle insert/update/delete responses in query_many #194
Handle insert/update/delete responses in query_many #194
Conversation
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.
Looks good to me!
defp result( | ||
{:ok, | ||
ok_packet( | ||
last_insert_id: last_insert_id, | ||
affected_rows: affected_rows, | ||
status_flags: status_flags, | ||
num_warnings: num_warnings | ||
)}, | ||
query, | ||
state | ||
) do | ||
result = %Result{ | ||
connection_id: state.client.connection_id, | ||
last_insert_id: last_insert_id, | ||
num_rows: affected_rows, | ||
num_warnings: num_warnings | ||
} | ||
|
||
{:ok, query, result, put_status(state, status_flags)} | ||
defp result({:ok, ok_packet(status_flags: status_flags) = result}, query, state) do | ||
{:ok, query, format_result(result, state), put_status(state, status_flags)} |
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.
Nice refactoring!
# Keep status flags from the last query. The results are given | ||
# to this function in reverse order, so it is the first one. |
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.
👍
lib/myxql/connection.ex
Outdated
), | ||
state | ||
) do | ||
columns = Enum.map(column_defs, &elem(&1, 1)) |
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.
columns = Enum.map(column_defs, &elem(&1, 1)) | |
columns = Enum.map(column_defs, &column_def(&1, :name)) |
test/myxql_test.exs
Outdated
assert {:ok, [%MyXQL.Result{num_rows: 1}]} = | ||
MyXQL.query_many(c.conn, "INSERT INTO integers VALUES (1);", [], query_type: :text) |
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.
could you assert on columns:
too?
update script for newer docker formats update workflow update grid for CI tests
update script for newer docker formats update workflow update grid for CI tests
update script for newer docker formats update workflow update grid for CI tests
update script for newer docker formats update workflow update grid for CI tests
* Permit geo ~> 4.0 (elixir-ecto#196) * Handle insert/update/delete responses in query_many (elixir-ecto#194) update script for newer docker formats update workflow update grid for CI tests * revert docker-compose to main remove comment update DB lang pairs revert some changes from master * Fix typespec * Revert ci.yml change --------- Co-authored-by: Greg Rychlewski <[email protected]> Co-authored-by: iacutone <[email protected]>
Closes #193
There are still a lot of other weird situations where query_many will break, see here. But this will fix the use case in the issue. If there is interest, we can continue fixing query_many completely but I need some time to play with the old PR to understand what was happening.