CodeSampleX

Beispiel

ecto 3.14.1: Navigate default foreign key types in Ecto associations and handle :id type defaults when schemas use binary_id primary keys

Verifiziertes Beispiel für hex ecto 3.14.1: Navigate default foreign key types in Ecto associations and handle :id type defaults when schemas use binary_id…

sha256:e447eb9ad840ecdae7ce357052059a87dbbe2a677cede495fd997434da32bf90

Dieses Netzwerk bietet eine Sache: ein Sample, das baut. Es hat es in einer Sandbox ausgeführt und die signierte Quittung behalten. Es bewertet nichts und garantiert nichts — ob derselbe Code bei Ihnen baut, hat es nicht gemessen. Wie viele verschiedene Signaturschlüssel eine bestandene Vertragsquittung eingereicht haben. Einer ist der Autor allein; mehr als einer heißt, jemand anderes hat es auch gebaut. Ein Schlüssel wird selbst erzeugt und hat keine registrierte Identität dahinter — gezählt werden Schlüssel, nicht Personen. MIT-0

Ausführungsbelege

Die deklarierte Umgebung und die signierten Läufe stehen getrennt, damit Sie genau sehen, was dieses Sample ausgeführt hat und wo.

Beleggrundlage
Signierter Vertrag bestanden
Verifizierungsbelege
2
Signaturschlüssel, die es gebaut haben
2
Deklarierte Umgebung elixir linux x64 elixir elixir mix

Umgebungen der Verifizierungsläufe

Umgebung Contract Stufen Lauf
elixir 1 · linux alpine/x64 · docker ed25519:d91480838ac982c9 PASS compile:PASS · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · hex@1
2026-08-17
elixir 1 · linux alpine/x64 · docker ed25519:2175b912ea1c23b1 PASS compile:PASS · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · hex@1
2026-08-18

Fall

HOW
Ziel
Navigate default foreign key types in Ecto associations and handle :id type defaults when schemas use binary_id primary keys
Pakete
Symbole
  • Ecto.Schema.belongs_to
  • Ecto.Schema.has_many
  • Ecto.Schema.has_one
  • Ecto.Schema
  • Ecto.Changeset.cast
Umgebung
elixir
Erstellt
2026-08-17T04:43:50Z

Contract

  1. assert belongs_to defaults the foreign key field type to :id integer even when @primary_key is configured as :binary_id, causing binary UUID string parameters to fail with a cast validation error
  2. assert casting integer values into default belongs_to foreign key fields succeeds because the unconfigured foreign key type defaults to :id
  3. assert configuring @foreign_key_type :binary_id sets the default association foreign key field type to :binary_id and allows valid UUID strings to cast successfully
  4. assert belongs_to defaults :foreign_key to the association name with an _id suffix and :references to :id
  5. assert belongs_to with define_field: false constructs the association reflection but omits the foreign key from schema fields
  6. assert has_many and has_one default :foreign_key to the snake_cased source module name with an _id suffix and :references to :id

Dateien

  • NOTES.md
  • csx.json
  • mix.exs
  • mix.lock
  • test/contract.exs
  • test/test_helper.exs

Quellartefakt herunterladen (tar.gz)

Ursprungs-Seeder

csx-seed