crash_orm 0.7.2

A simple, typed ORM for Postgres
//! Contains the definition of a column of an entity.
//!
//! These columns will be auto generated by the derive macro, so you shouldn't need to use them manually.

use std::marker::PhantomData;

use crate::prelude::{BoxedSql, ColumnType, Entity};

/// Struct holding information about a column of an entity.
///
/// These columns will be automatically generated by the entity derive macro.
pub struct EntityColumn<T: ColumnType, U: Entity> {
    name: &'static str,
    phantom_1: PhantomData<T>,
    phantom_2: PhantomData<U>,
}

impl<T: ColumnType, U: Entity> EntityColumn<T, U> {
    /// Creates an [EntityColumn] for a column name.
    ///
    /// INTERNAL USE ONLY!
    #[doc(hidden)]
    pub const fn new(name: &'static str) -> EntityColumn<T, U> {
        Self {
            name,
            phantom_1: PhantomData,
            phantom_2: PhantomData,
        }
    }

    /// Convert [EntityColumn] into a [BoxedSql]
    pub(crate) fn get_sql(&self) -> BoxedSql {
        BoxedSql::new(self.name.to_string(), vec![])
    }
}