Find a cleaner solution for the return_skipped_upsert? logic introduced in #626
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 40/100
Research direction
Start by reviewing PR #626 and the current return_skipped_upsert? logic, then trace how bulk_upserts builds its PostgreSQL upsert statement and how Ecto handles the :returning option. Compare the extra-query and data-wrangling approach with the attempted upsert-condition marker; done means a supported, maintainable way to identify skipped records without the current workaround.
Written by the indexing model from the issue text.
Description
Code of Conduct
- I agree to follow this project's Code of Conduct
AI Policy
- I agree to follow this project's AI Policy, or I agree that AI was not used while creating this issue.
Is your feature request related to a problem? Please describe.
https://github.com/ash-project/ash_postgres/pull/626 adds support for returning skipped records from bulk_upserts. but we need to do an extra query and some data wrangling to achieve it.
Describe the solution you'd like
I tried doing it as part of the upsert statement by adding the upsert_condition logic to the update statement and add a marker to the return values to check if one of the inserts was actually skipped because of the condition logic.
- CASE WHEN in DO UPDATE SET was successfully implemented - the conditional logic works, SQL generates correctly
- The goal was to add the condition to RETURNING like:
RETURNING id, price, (price != EXCLUDED.price) AS met_upsert_condition - PostgreSQL supports this - expressions in RETURNING are valid SQL
- But Ecto doesn't expose a way to do it:
- The :returning option flows through quote_names() which calls quote_name/1 on each item
- quote_name/1 only has function clauses for atoms and strings - it quotes them as identifiers
- If {:unsafe_fragment, "..."} is passed (like :conflict_target supports), it crashes with FunctionClauseError because there's no matching clause
- If a plain string like "(condition) AS met" is passed, it gets quoted as "(condition) AS met" which is an invalid identifier
Describe alternatives you've considered
No response
Additional context
No response
- Dominant language
- Elixir
- Stars
- 191
- Forks
- 186
- Avg merge
- 16h 4m
- Merged PRs (30d)
- 17
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from ash-project/ash_postgres
-
Temporal: an update or destroy as of an instant doesn't carry into later versionsPossibly taken @hoanle0126 claimed this 13 days ago. Open
Difficulty 5/5 Over a week Newbie friendliness 15/100
ash-project/ash_postgres#915 · 1 comment ·
Maintainers usually reply within 1 day
-
has_create_action?/1 excludes manual creates, making the #49 nullability fix inert on AshEvents resourcesMay be free again @Mckay-Hinds claimed this 18 days ago, and no pull request is open. Open
Difficulty 3/5 1-2 days Newbie friendliness 76/100
ash-project/ash_postgres#851 · 9 comments ·
Maintainers usually reply within 1 day
-
enhancement
Difficulty 4/5 3-5 days Newbie friendliness 35/100
ash-project/ash_postgres#650 · 6 comments ·
Maintainers usually reply within 1 day
-
bug
Difficulty 4/5 3-5 days Newbie friendliness 35/100
ash-project/ash_postgres#642 · 5 comments ·
Maintainers usually reply within 1 day
-
enhancement good first issue
Difficulty 4/5 3-5 days Newbie friendliness 48/100
ash-project/ash_postgres#538 · 1 comment ·
Maintainers usually reply within 1 day
All issues in ash-project/ash_postgres
Similar issues
-
@swmansion/popcorn: published .d.ts files lack extensions on relative imports, breaking moduleResolution node16/nodenextPossibly taken @Huyvux12 claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
software-mansion/popcorn#929 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
ash-project/ash#3127 ·
Maintainers usually reply within 1 day
-
Bug: Table layout and date column are cut off on mobile screens on the Tournaments -> History pageOpenbug
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
hexlet-codebattle/codebattle#2375 ·
-
Bug
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
wintermeyer/vutuv#2388 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100