Skip to content

chore: accept a counter option in prepare_query/3#4714

Open
zachdaniel wants to merge 4 commits intoelixir-ecto:masterfrom
zachdaniel:merge-support
Open

chore: accept a counter option in prepare_query/3#4714
zachdaniel wants to merge 4 commits intoelixir-ecto:masterfrom
zachdaniel:merge-support

Conversation

@zachdaniel
Copy link
Copy Markdown
Contributor

No description provided.

@greg-rychlewski
Copy link
Copy Markdown
Member

Out of curiosity what problem does this solve?

@josevalim
Copy link
Copy Markdown
Member

@zachdaniel is implementing MERGE, which is basically multiple insert, update, etc. queries spliced into one.

{query, params, key} = plan(query, operation, adapter)
{cast_params, dump_params} = Enum.unzip(params)
key = if query_cache?, do: key, else: :nocache
key = if query_cache?, do: {key, counter}, else: :nocache
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@zachdaniel I thought it would be better to always add the counter, to reduce the number of branches, but it seems that either using a list is wrong or we are messing with the key in an incompatible way. Can you please take a deeper look?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Sorry I'm not quite following.

it seems that either using a list is wrong or we are messing with the key in an incompatible way.

WDYM by using a list?

Is this about the test failures? The seem like timeouts in the GH actions to me but maybe I'm missing something.

Copy link
Copy Markdown
Member

@josevalim josevalim Apr 11, 2026

Choose a reason for hiding this comment

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

I am not so sure. I have cloned ecto, pulled your branch, rebased master, and ECTO_PATH=../ecto ECTO_ADAPTER=pg mix test in ecto_sql fails for me.

And I decided to always return a tuple with the counter so we don't have hidden behaviour depending if counter is zero or not.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I will do the same and investigate 👌

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.

3 participants