Replicant.Decoder.OidDatabase (Replicant v1.3.0)

Copy Markdown View Source

Maps a numeric PostgreSQL type ID to a descriptive string.

Implementation borrowed from Supabase Realtime, Cainophile, and epgsql.

1.3.0: the mapping is a compile-time map (Map.get/3, O(1)) instead of a ~140-clause sequential case — every unmapped OID (each enum / user-defined type) previously walked all clauses on each Relation message.

Summary

Functions

Maps a numeric PostgreSQL type ID to a descriptive string.

Functions

name_for_type_id(type_id)

@spec name_for_type_id(non_neg_integer()) :: String.t() | non_neg_integer()

Maps a numeric PostgreSQL type ID to a descriptive string.

Examples

iex> name_for_type_id(1700)
"numeric"

iex> name_for_type_id(25)
"text"

iex> name_for_type_id(3802)
"jsonb"