Skip to main content

DrizzlePostgresColumn

Trait DrizzlePostgresColumn 

Source
pub trait DrizzlePostgresColumn: Sized {
    type SQLType: DataType;

    const SQL_TYPE: &'static str;
    const NEEDS_CREATE_TYPE: bool = false;

    // Required method
    fn encode(&self) -> PostgresValue<'_>;

    // Provided method
    fn encode_owned(self) -> OwnedPostgresValue { ... }
}
Expand description

Stub trait when no postgres driver is enabled — allows enum derives to compile without a driver feature, but the table macro’s TryFrom impls won’t be generated.

The blanket From<Self> for PostgresValue owns the encoded value because insert/update models may store SQL fragments after the source value is dropped. Call encode() directly when you need an immediate borrowed value. Override encode_owned() when consuming self can avoid cloning owned data.

Required Associated Constants§

Source

const SQL_TYPE: &'static str

PostgreSQL column type: "text", "integer", or native enum type name

Provided Associated Constants§

Source

const NEEDS_CREATE_TYPE: bool = false

Whether this requires a CREATE TYPE (native PG enum).

Required Associated Types§

Source

type SQLType: DataType

Drizzle SQL type marker for this column.

Use one of the built-in PostgreSQL markers, such as Text, Int4, Bytea, Boolean, Numeric, Enum, or Any.

Required Methods§

Source

fn encode(&self) -> PostgresValue<'_>

Convert self to a PostgresValue for insertion/updates.

Provided Methods§

Source

fn encode_owned(self) -> OwnedPostgresValue

Convert self to an owned PostgreSQL value for stored bind parameters.

The default implementation owns the borrowed result of encode. Override this for wrappers that can move an internal string or byte buffer directly into the SQL parameter.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§