Skip to main content

toasty_sql/stmt/
create_type.rs

1use super::Statement;
2
3use toasty_core::schema::db::TypeEnum;
4
5/// A `CREATE TYPE ... AS ENUM (...)` statement.
6#[derive(Debug, Clone)]
7pub struct CreateType {
8    /// The enum type definition.
9    pub ty: TypeEnum,
10}
11
12impl Statement {
13    /// Creates a `CREATE TYPE ... AS ENUM (...)` statement from a [`TypeEnum`].
14    pub fn create_enum_type(ty: &TypeEnum) -> Self {
15        CreateType { ty: ty.clone() }.into()
16    }
17}
18
19impl From<CreateType> for Statement {
20    fn from(value: CreateType) -> Self {
21        Self::CreateType(value)
22    }
23}