Find a cleaner solution for the return_skipped_upsert? logic introduced in #626
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
调研方向
首先检查 PR #626 和当前的 return_skipped_upsert? 逻辑,然后跟踪 bulk_upserts 如何构建其 PostgreSQL upsert 语句,以及 Ecto 如何处理 :returning 选项。将额外查询和数据处理的方法与尝试过的 upsert 条件标记进行比较;完成标准是找到一种受支持且可维护的方法,在不使用当前 workaround 的情况下识别被跳过的记录。
由索引模型根据 Issue 内容生成。
描述
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
- 主要语言
- Elixir
- 星标
- 191
- 派生
- 186
- 平均合并
- 16 小时 4 分钟
- 30 天内合并 PR
- 17
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
ash-project/ash_postgres 的其他 Issue
-
Temporal: an update or destroy as of an instant doesn't carry into later versions可能已有人在做 @hoanle0126 于 13 天前认领。 未关闭
难度 5/5 一周以上 新手友好度 15/100
ash-project/ash_postgres#915 · 1 条评论 ·
维护者通常 1 天内回复
-
has_create_action?/1 excludes manual creates, making the #49 nullability fix inert on AshEvents resources可能重新可做 @Mckay-Hinds 于 18 天前认领,目前没有进行中的 PR。 未关闭
难度 3/5 1-2 天 新手友好度 76/100
ash-project/ash_postgres#851 · 9 条评论 ·
维护者通常 1 天内回复
-
enhancement
难度 4/5 3-5 天 新手友好度 35/100
ash-project/ash_postgres#650 · 6 条评论 ·
维护者通常 1 天内回复
-
bug
难度 4/5 3-5 天 新手友好度 35/100
ash-project/ash_postgres#642 · 5 条评论 ·
维护者通常 1 天内回复
-
enhancement good first issue
难度 4/5 3-5 天 新手友好度 48/100
ash-project/ash_postgres#538 · 1 条评论 ·
维护者通常 1 天内回复
查看 ash-project/ash_postgres 的全部 Issue
相似的 Issue
-
@swmansion/popcorn: published .d.ts files lack extensions on relative imports, breaking moduleResolution node16/nodenext可能已有人在做 @Huyvux12 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 78/100
software-mansion/popcorn#929 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 85/100
ash-project/ash#3127 ·
维护者通常 1 天内回复
-
Bug: Table layout and date column are cut off on mobile screens on the Tournaments -> History page未关闭bug
难度 2/5 1-3 小时 新手友好度 74/100
hexlet-codebattle/codebattle#2375 ·
-
Bug
难度 2/5 1-3 小时 新手友好度 68/100
wintermeyer/vutuv#2388 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 74/100