Supported types

Base types

PostgrsQL typeRust type
bool, booleanbool
"char"i8
smallint, int2, smallserial, serial2i16
int, int4, serial, serial4i32
bigint, int8, bigserial, serial8i64
real, float4f32
double precision, float8f64
textString
varcharString
byteaVec<u8>
timestamp without time zone, timestamp (*)time::PrimitiveDateTime
timestamp with time zone, timestamptz (*)time::OffsetDateTime
date(*)time::Date
time(*)time::Time
json(*)serde_json::Value
jsonb(*)serde_json::Value
uuid(*)uuid::Uuid
inet(*)std::net::IpAddr
macaddr(*)eui48::MacAddress
numeric (*)rust_decimal::Decimal

(*) Optional extra types.

Custom types

Custom types like enums, composites and domains will be generated automatically by inspecting your database. The only requirement for your custom types is that they should be based on other supported types (base or custom).

Cornucopia is aware of your types' namespaces (what PostgreSQL calls schemas), so it will correctly handle custom types like my_schema.my_custom_type.

Note

Domains are unwrapped into their inner types in your Rust queries.

Array types

Cornucopia supports one-dimensional arrays when the element type is also a type supported. That is, Cornucopia supports example_elem_type[] if example_elem_type is itself a type supported by Cornucopia (base or custom).