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

Handle insert/update/delete responses in query_many #194

Merged

Conversation

greg-rychlewski
Copy link
Member

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.

Copy link
Member

@wojtekmach wojtekmach left a 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!

Comment on lines -278 to +279
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)}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice refactoring!

Comment on lines +290 to +291
# Keep status flags from the last query. The results are given
# to this function in reverse order, so it is the first one.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

),
state
) do
columns = Enum.map(column_defs, &elem(&1, 1))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
columns = Enum.map(column_defs, &elem(&1, 1))
columns = Enum.map(column_defs, &column_def(&1, :name))

Comment on lines 212 to 213
assert {:ok, [%MyXQL.Result{num_rows: 1}]} =
MyXQL.query_many(c.conn, "INSERT INTO integers VALUES (1);", [], query_type: :text)
Copy link
Member

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?

@greg-rychlewski greg-rychlewski merged commit 128f350 into elixir-ecto:master Aug 20, 2024
9 checks passed
@greg-rychlewski greg-rychlewski deleted the query_many_insert_update branch August 20, 2024 10:34
ckoch-cars pushed a commit to carsdotcom/myxql that referenced this pull request Oct 10, 2024
update script for newer docker formats

update workflow

update grid for CI tests
ckoch-cars pushed a commit to carsdotcom/myxql that referenced this pull request Oct 10, 2024
update script for newer docker formats

update workflow

update grid for CI tests
ckoch-cars pushed a commit to carsdotcom/myxql that referenced this pull request Oct 10, 2024
update script for newer docker formats

update workflow

update grid for CI tests
iacutone pushed a commit to carsdotcom/myxql that referenced this pull request Oct 22, 2024
update script for newer docker formats

update workflow

update grid for CI tests
ckoch-cars added a commit to carsdotcom/myxql that referenced this pull request Oct 22, 2024
* 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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error when use UPDATE or INSERT on query_many
2 participants