use super::{Identifier, MssqlType};
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct MssqlColumn {
name: Identifier,
ty: MssqlType,
nullable: bool,
}
impl MssqlColumn {
pub const fn new(name: Identifier, ty: MssqlType, nullable: bool) -> Self {
Self { name, ty, nullable }
}
pub const fn name(&self) -> &Identifier {
&self.name
}
pub const fn ty(&self) -> &MssqlType {
&self.ty
}
pub const fn nullable(&self) -> bool {
self.nullable
}
pub(crate) fn to_sql(&self) -> String {
let nullability = if self.nullable { "NULL" } else { "NOT NULL" };
format!(
"{} {} {nullability}",
self.name.quoted_sql(),
self.ty.to_sql()
)
}
}