Selecto.Output.TypeCoercion (Selecto v0.3.8)
Database type coercion system for transforming raw database values to appropriate Elixir types based on PostgreSQL column types.
This module provides configurable type coercion strategies and can be extended to support custom type mappings and coercion functions.
Link to this section Summary
Functions
Batch coerce a list of values with their corresponding column types.
Coerce a database value to its appropriate Elixir type.
Get the Elixir type for a given PostgreSQL column type.
Get all supported PostgreSQL type mappings.
Link to this section Functions
batch_coerce(values, column_types, strategy \\ :safe, custom_coercions \\ %{})
Batch coerce a list of values with their corresponding column types.
This is more efficient than coercing values one by one when you have column type information for all values.
coerce_value(value, column_type \\ nil, strategy \\ :safe, custom_coercions \\ %{})
Coerce a database value to its appropriate Elixir type.
parameters
Parameters
value- The raw database valuecolumn_type- The PostgreSQL column type (optional)strategy- Coercion strategy (:strict, :safe, :ignore, :custom)custom_coercions- Map of custom coercion functions
coercion-strategies
Coercion Strategies
:strict- Raise on coercion errors:safe- Return original value on coercion errors:ignore- Skip coercion, return raw values:custom- Use custom coercion functions
get_elixir_type(postgres_type)
Get the Elixir type for a given PostgreSQL column type.
supported_types()
Get all supported PostgreSQL type mappings.