Selecting a field whose type is an embedded resource raises "not found in resource lookup"
还没有人认领这个 Issue。
评估
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 新手友好度
- 72/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 领域
- backend
调研方向
Start in lib/ash_lua/fields.ex, especially select_for_type/3 around lines 254–257, and trace how ctx.lookup is built from resource_lookup/1 and how the manifest stores embedded definitions in manifest.types. Reproduce with the listed embedded attribute, union, or array case and inspect selection of a sub-field. Done means selecting embedded values returns them without lookup errors, with the suggested default public attributes and no extra select or load.
由索引模型根据 Issue 内容生成。
描述
Seen on 0.2.3 and still on main (878d144e).
A field whose type is, or contains, an embedded resource cannot be selected in fields. This covers an :embedded_resource attribute, a union whose members are embedded resources, and {:array, Embedded}. The select raises:
** (RuntimeError) Resource MyApp.SomeEmbedded not found in resource lookup
(ash) Ash.Info.Manifest.get_resource!/2
(ash_lua) AshLua.Fields.select_for_type/3 # lib/ash_lua/fields.ex ~254-257
Cause
Ash.Info.Manifest.Generator puts embedded resources in manifest.types, not manifest.resources. AshLua builds ctx.lookup from resource_lookup/1 only. Then select_for_type/3 matches kind in [:resource, :embedded_resource] and calls Manifest.get_resource!(ctx.lookup, mod), which fails for the embedded module.
Repro
- Take a resource with an attribute
profilof an embedded type (or a union of embedded types), exposed through a read action on the Lua surface. - Run
x.list({ fields = { "id", "profil" } }), or select a sub-field of it. - It raises instead of returning the embedded value.
Suggested fix
Treat an embedded resource like a typed map. Take its definition from manifest.types (type.resource), default to all public attributes, and allow subselection. Embedded values are already loaded with the parent, so select = [] and load = [] for them.
Workaround we use
We pass our own manifest: to AshLua.Eval.run/2, with each embedded type rewritten to kind: :map.
- 主要语言
- Elixir
- 星标
- 15
- 派生
- 5
- 平均合并
- 2 小时 16 分钟
- 30 天内合并 PR
- 1
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
ash-project/ash_lua 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 82/100
ash-project/ash_lua#24 ·
查看 ash-project/ash_lua 的全部 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