drizzle-postgres 0.3.0

A type-safe SQL query builder for Rust
Documentation
use drizzle_core::SQLColumn;

use crate::values::PostgresValue;
/// A column of a `PostgreSQL` table, with its auto-increment settings.
///
/// Implemented by `#[PostgresTable]` for every column type it generates.
pub trait PostgresColumn<'a>: SQLColumn<'a, PostgresValue<'a>> {
    /// `true` for a `serial` column.
    const SERIAL: bool = false;
    /// `true` for a `bigserial` column.
    const BIGSERIAL: bool = false;
    /// `true` for a `GENERATED ... AS IDENTITY` column.
    const GENERATED_IDENTITY: bool = false;
    /// `true` = GENERATED ALWAYS AS IDENTITY, `false` = GENERATED BY DEFAULT AS IDENTITY.
    /// Only meaningful when `GENERATED_IDENTITY` is `true`.
    const IDENTITY_ALWAYS: bool = true;
}

impl<'a, T> PostgresColumn<'a> for &T
where
    T: PostgresColumn<'a>,
    for<'r> &'r T: SQLColumn<'a, PostgresValue<'a>>,
{
    const SERIAL: bool = T::SERIAL;
    const BIGSERIAL: bool = T::BIGSERIAL;
    const GENERATED_IDENTITY: bool = T::GENERATED_IDENTITY;
    const IDENTITY_ALWAYS: bool = T::IDENTITY_ALWAYS;
}