Struct sea_query::extension::postgres::TypeCreateStatement [−][src]
pub struct TypeCreateStatement { /* fields omitted */ }
This is supported on crate feature
backend-postgres
only.Implementations
Create enum as custom type
use sea_query::{*, extension::postgres::Type};
enum FontFamily {
Type,
Serif,
Sans,
Monospace,
}
impl Iden for FontFamily {
fn unquoted(&self, s: &mut dyn std::fmt::Write) {
write!(s, "{}", match self {
Self::Type => "font_family",
Self::Serif => "serif",
Self::Sans => "sans",
Self::Monospace => "monospace",
}).unwrap();
}
}
assert_eq!(
Type::create()
.as_enum(FontFamily::Type)
.values(vec![FontFamily::Serif, FontFamily::Sans, FontFamily::Monospace])
.to_string(PostgresQueryBuilder),
r#"CREATE TYPE "font_family" AS ENUM ('serif', 'sans', 'monospace')"#
);
pub fn values<T, I>(&mut self, values: I) -> &mut Self where
T: IntoIden,
I: IntoIterator<Item = T>,
pub fn build_collect<T: TypeBuilder>(
&self,
type_builder: T,
collector: &mut dyn FnMut(Value)
) -> String
pub fn build_collect_ref<T: TypeBuilder>(
&self,
type_builder: &T,
collector: &mut dyn FnMut(Value)
) -> String
Build corresponding SQL statement and return SQL string
Trait Implementations
Returns the “default value” for a type. Read more
Auto Trait Implementations
impl !RefUnwindSafe for TypeCreateStatement
impl Send for TypeCreateStatement
impl Sync for TypeCreateStatement
impl Unpin for TypeCreateStatement
impl !UnwindSafe for TypeCreateStatement
Blanket Implementations
Mutably borrows from an owned value. Read more
type Output = T
type Output = T
Should always be Self