Parametrized queries not working for `Electric.Client.poll/4` in embedded mode
还没有人认领这个 Issue。
评估
调研方向
从 Electric.Client.Embedded.request_to_params/1 开始,将其处理方式与通过 Plug 和 Electric.Shapes.Api.validate/2 的 HTTP 路径进行比较。使用 positional where 参数运行 embedded Electric.Client.poll/4 的复现;当同一个 ShapeDefinition 能够在 embedded 模式下正常工作且不再出现 parameter-not-provided 错误时,即完成。
由索引模型根据 Issue 内容生成。
描述
Versions
- Client:
electric_client(Elixir) 0.10.1 - Electric: 1.6.2 (also reproducible on
main)
Bug description
A ShapeDefinition whose where: clause uses positional parameters ($1, $2, …) with params: substitution works over HTTP but fails under Electric.Client.embedded/1 with "At location N: parameter $1 was not provided":
{:ok, client} = Electric.Client.embedded()
shape =
Electric.Client.ShapeDefinition.new!("things",
where: "organization_id IN ($1::uuid, $2::uuid)",
params: %{1 => uuid_a, 2 => uuid_b}
)
Electric.Client.poll(client, shape, Electric.Client.ShapeState.new(offset: "now"))
# => {:error, %Electric.Client.Error{
# message: %{errors: %{where: ["At location 20: parameter $1 was not provided"]}}, ...}}
Root cause: ShapeDefinition.params/2 defaults to format: :query and emits bracket-flat keys (%{"params[1]" => ..., "params[2]" => ...}) — correct for HTTP, where Plug's fetch_query_params re-nests them into %{"params" => %{"1" => ..., "2" => ...}} before Electric.Shapes.Api.Params's Ecto cast sees them. Electric.Client.Embedded.request_to_params/1 skips Plug and Map.merges the bracket-flat map straight into Api.validate/2; the Ecto schema has no field "params[1]", silently drops both keys, and the SQL parser then rejects $1.
Expected behavior
Electric.Client.Embedded should accept the same ShapeDefinition shape as Electric.Client.Fetch.HTTP does, including parameterized where: clauses. Fix is to re-nest one level of bracket keys in Embedded.request_to_params/1 before handing off to Api.validate/2 — equivalent to what Plug does for the HTTP path.
- 主要语言
- TypeScript
- 星标
- 10.4k
- 派生
- 399
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
electric-sql/electric 的其他 Issue
-
camelToSnake and snakeCamelMapper() drop the underscore when a digit precedes a camelCase boundary未关闭
难度 2/5 1-3 小时 新手友好度 85/100
electric-sql/electric#4855 ·
-
ShapeStream does not notify subscribers when it gives up on a non-Error value可能已有人在做 @Tyagiquamar 于 19 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 72/100
electric-sql/electric#4830 ·
-
@electric-sql/client throws SecurityError on import when the browser blocks site storage (typeof localStorage outside try)可能已有人在做 @mohanedmoh 于 37 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 72/100
electric-sql/electric#4826 · 1 条评论 ·
-
agents-chat-starter: spawn PUT goes to the durable-streams proxy, so no entity is created and agents never wake可能已有人在做 @adityavkk 于 133 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 78/100
electric-sql/electric#4687 ·
-
feature request triage
难度 2/5 1-3 小时 新手友好度 68/100
electric-sql/electric#4150 · 1 条评论 ·
查看 electric-sql/electric 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 82/100
software-mansion/argent#1946 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 63/100
podman-desktop/podman-desktop#20216 ·
维护者通常 1 天内回复
-
[Type] Bug
难度 2/5 1-3 小时 新手友好度 76/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 5 天内回复
-
难度 2/5 1-3 小时 新手友好度 65/100
omdsh-dev/DSH-better-sidebar#1205 ·
维护者通常 3 天内回复