Ejemplo
Inspect Ecto parameterized type representation, normalize Ecto.Enum mapped inputs, and distinguish scalar from composite cast failure shapes
sha256:6c6fb613f0a59efec76da1c4c4b630f16524102c374f9718430edeb1abd1742e
PUBLISHED
L3_CONTRACT_PASS
MIT-0
Evidencia de ejecución
Separamos el entorno declarado de las ejecuciones firmadas para mostrar qué se demostró.
Base de evidenciaContrato firmado aprobado
Recibos de verificación1
Nivel de verificaciónL3_CONTRACT_PASS
Entorno declarado
- Contexto de ejecución
- elixir 1
- Sistema operativo
- linux
- Arquitectura
- x64
- Runtime
- elixir 1
- Lenguaje
- elixir
- Gestor de paquetes
- mix
Entornos de las ejecuciones de verificación
- Contexto de ejecución
- elixir 1
- Sistema operativo
- linux alpine · musl
- Arquitectura
- x64
- Runtime
- elixir 1
- Lenguaje
- elixir
- Gestor de paquetes
- mix
- Ejecución
- container · docker
CONTAINER_RUN · compile:PASS · contract:PASS · load:PASS · resolve:PASS · hex@1 · 2026-08-17
Caso
- Objetivo
- Inspect Ecto parameterized type representation, normalize Ecto.Enum mapped inputs, and distinguish scalar from composite cast failure shapes HOW
- Paquetes
-
ecto 3.14.1
- Entorno
- elixir 1
- Creado
- 2026-08-17T04:43:50Z
Lo que suele suponerse
Parameterized types in Ecto schemas are represented as three-element tuples of {:parameterized, module, params}, and casting an Ecto.Enum with mapped values accepts the underlying database representation.
El autor de la muestra anotó aquí lo que un desarrollador o un modelo esperaría. El contrato de abajo es lo que realmente se ejecutó.
Contrato
- assert schema type for an Ecto.Enum is a 2-element tuple {:parameterized, {Ecto.Enum, info}} rather than a 3-element tuple, Ecto.Type.parameterized? identifies it, and Ecto.Type.type returns the underlying primitive storage type
- assert casting an Ecto.Enum with mapped values accepts atom keys, string names, and raw mapped integers, while rejecting stringified integers with inclusion metadata
- assert Ecto.Enum reflections distinguish between Elixir value atoms, database dump values, and key-value mappings
- assert Ecto.Type.cast! returns normalized scalar values and raises Ecto.CastError on failure, while invalid composite arrays collapse to :error and changesets omit the failing element index
Archivos
- NOTES.md
- csx.json
- lib/account.ex
- mix.exs
- mix.lock
- test/contract_test.exs
- test/test_helper.exs
Descargar el artefacto de código fuente (tar.gz)
Seeder de origen
csx-seed
Recibos de verificación
- elixir 1 · linux alpine/x64 · docker · CONTAINER_RUN · compile:PASS · contract:PASS · load:PASS · resolve:PASS · hex@1 · 2026-08-17 · ed25519:d91480838ac982c9