示例
Manage embedded schemas with cast_embed and put_embed, handle on_replace lifecycle traps, and navigate changeset field, validator, and constraint contracts
sha256:ae752db5d7927ae9032a038840a9dc4c05edb909194c15efd4a16dd03309aff5
PUBLISHED
L3_CONTRACT_PASS
MIT-0
执行证据
分开显示声明环境和签名验证运行,明确样本的证明范围。
证据依据签名契约通过
验证回执1
验证级别L3_CONTRACT_PASS
声明的环境
- 执行上下文
- elixir 1
- 操作系统
- linux
- 架构
- x64
- 运行时
- elixir 1
- 语言
- elixir
- 包管理器
- mix
验证运行环境
- 执行上下文
- elixir 1
- 操作系统
- linux alpine · musl
- 架构
- x64
- 运行时
- elixir 1
- 语言
- elixir
- 包管理器
- mix
- 执行方式
- container · docker
CONTAINER_RUN · compile:PASS · contract:PASS · load:PASS · resolve:PASS · hex@1 · 2026-08-17
案例
- 目标
- Manage embedded schemas with cast_embed and put_embed, handle on_replace lifecycle traps, and navigate changeset field, validator, and constraint contracts HOW
- 包
-
ecto 3.14.1
- 环境
- elixir 1
- 创建时间
- 2026-08-17T04:42:59Z
契约
- assert put_embed rejects string-keyed external parameter maps with ArgumentError while cast_embed accepts the same external params
- assert updating an embeds_many or embeds_one collection that drops existing items raises RuntimeError unless on_replace is explicitly configured
- assert cast_embed on an embeds_many collection matches params by primary key id to update existing items, creates new items for params lacking id, and marks omitted items for deletion when on_replace is :delete
- assert fetch_field returns {:changes, value} for changed fields and {:data, value} for unchanged schema fields instead of standard {:ok, value} tuples, while fetch_change returns {:ok, value}
- assert validate_change raises Protocol.UndefinedError if the validator callback returns a boolean or tuple instead of an enumerable keyword-error list
- assert validate_change is completely bypassed when the field is unchanged in params even if present on the underlying schema struct
- assert unique_constraint and foreign_key_constraint only record metadata on a source-backed changeset and leave valid? true with empty errors
文件
- NOTES.md
- csx.json
- lib/ecto_embeds.ex
- mix.exs
- mix.lock
- test/contract_test.exs
- test/test_helper.exs
下载源代码构件 (tar.gz)
原始种子者
csx-seed
验证回执
- elixir 1 · linux alpine/x64 · docker · CONTAINER_RUN · compile:PASS · contract:PASS · load:PASS · resolve:PASS · hex@1 · 2026-08-17 · ed25519:d91480838ac982c9