kura_types (kura v2.17.1)
View SourceType system for casting, dumping, and loading values between Erlang and PostgreSQL.
Supported types: id, integer, float, string, text, boolean,
date, utc_datetime, uuid, jsonb, {array, Type}.
Summary
Functions
Coerce external input to an Erlang term for the given type.
Convert an Erlang term to a pgo-compatible value for storage.
Map a PostgreSQL catalog type name (udt_name, e.g. ~"int4") to a kura
field type - the inverse of to_pg_type/1. Used by schema introspection
(rebar3 kura gen_schemas) to bootstrap schemas from an existing database.
Convert a pgo result value back to an Erlang term.
Return the PostgreSQL DDL type string for a kura type.
Types
-type kura_type() :: id | integer | bigint | smallint | float | decimal | string | text | binary | boolean | date | time | utc_datetime | naive_datetime | uuid | jsonb | {enum, [atom()]} | {array, kura_type()} | {encrypted, kura_type()} | vector | {vector, pos_integer()} | {embed, embeds_one | embeds_many, module()} | {custom, module()}.
Functions
Coerce external input to an Erlang term for the given type.
Convert an Erlang term to a pgo-compatible value for storage.
-spec from_pg_type(binary(), #{serial => boolean(), char_max_length => non_neg_integer()}) -> kura_type() | {unsupported, binary()}.
Map a PostgreSQL catalog type name (udt_name, e.g. ~"int4") to a kura
field type - the inverse of to_pg_type/1. Used by schema introspection
(rebar3 kura gen_schemas) to bootstrap schemas from an existing database.
Opts supplies context the type name alone does not carry:
char_max_length- distinguishes~"varchar"at 255 (string) from any other length (text).serial- an~"int8"column with anextvaldefault is kura'sid(BIGSERIAL); a plain~"int8"isbigint.
float4 (REAL) widens to float since kura models a single float type
(DOUBLE PRECISION). Returns {unsupported, TypeName} for a PG type kura
does not model (including native CREATE TYPE ... AS ENUM types), so the
caller can skip the field and warn rather than guessing.
Convert a pgo result value back to an Erlang term.
Return the PostgreSQL DDL type string for a kura type.