Skip to main content

drizzle_postgres/traits/
column.rs

1use drizzle_core::SQLColumn;
2
3use crate::values::PostgresValue;
4pub trait PostgresColumn<'a>: SQLColumn<'a, PostgresValue<'a>> {
5    const SERIAL: bool = false;
6    const BIGSERIAL: bool = false;
7    const GENERATED_IDENTITY: bool = false;
8    /// `true` = GENERATED ALWAYS AS IDENTITY, `false` = GENERATED BY DEFAULT AS IDENTITY.
9    /// Only meaningful when `GENERATED_IDENTITY` is `true`.
10    const IDENTITY_ALWAYS: bool = true;
11}
12
13impl<'a, T> PostgresColumn<'a> for &T
14where
15    T: PostgresColumn<'a>,
16    for<'r> &'r T: SQLColumn<'a, PostgresValue<'a>>,
17{
18    const SERIAL: bool = T::SERIAL;
19    const BIGSERIAL: bool = T::BIGSERIAL;
20    const GENERATED_IDENTITY: bool = T::GENERATED_IDENTITY;
21    const IDENTITY_ALWAYS: bool = T::IDENTITY_ALWAYS;
22}