arrow_sql_server/mssql/
column.rs1use super::{Identifier, MssqlType};
4
5#[derive(Debug, Clone, PartialEq, Eq)]
7pub struct MssqlColumn {
8 name: Identifier,
9 ty: MssqlType,
10 nullable: bool,
11}
12
13impl MssqlColumn {
14 pub const fn new(name: Identifier, ty: MssqlType, nullable: bool) -> Self {
16 Self { name, ty, nullable }
17 }
18
19 pub const fn name(&self) -> &Identifier {
21 &self.name
22 }
23
24 pub const fn ty(&self) -> &MssqlType {
26 &self.ty
27 }
28
29 pub const fn nullable(&self) -> bool {
31 self.nullable
32 }
33
34 pub(crate) fn to_sql(&self) -> String {
35 let nullability = if self.nullable { "NULL" } else { "NOT NULL" };
36 format!(
37 "{} {} {nullability}",
38 self.name.quoted_sql(),
39 self.ty.to_sql()
40 )
41 }
42}