The primary key type of the five schemas in StatifierRouter.Schema:
the id of a row, whatever type the host's migration gave it.
StatifierRouter.Migrations.up/1 builds id as the host repo's
implicit primary key - a bigserial unless the repo's
:migration_primary_key says otherwise - or, under its :primary_key
option, as the type and default the host names, a text id for
instance. The database fills the column in either way, and a schema
reads it back as the database holds it: an integer from an integer
column, a string from a text column. The package never makes up an id
itself and never compares one to anything but another id of the same
table.
Casting is exactly Ecto's own :id type: an integer casts to itself,
a string that spells one casts to that integer ("42" to 42), and
any other string is refused, so a cast that worked or failed under
the default key works or fails the same way. A text id is therefore
never cast: a host on a text key looks a row up with a where clause
that binds the id uncast, where: fragment("? = ?", a.id, ^id),
rather than with Repo.get/2 or a changeset cast. The package's own
reads bind ids that way too: they never cast an id.
A refused cast names this type rather than :id, as it has since
0.8.0 put the four schemas on it. A changeset error's metadata reads
type: StatifierRouter.Schema.Id where it read type: :id, and an
Ecto.Query.CastError says the value "cannot be cast to type
StatifierRouter.Schema.Id" where it said "cannot be cast to type :id".
The values refused are the same; only a host that matches on the
metadata's :type or on the message text sees the difference.
Summary
Functions
Callback implementation for Ecto.Type.embed_as/1.
Callback implementation for Ecto.Type.equal?/2.
Types
Functions
Callback implementation for Ecto.Type.embed_as/1.
Callback implementation for Ecto.Type.equal?/2.