pub struct ColumnDef { /* private fields */ }
Expand description
Specification of a table column
Implementations§
Source§impl ColumnDef
impl ColumnDef
Sourcepub fn new_with_type<T>(name: T, types: ColumnType) -> ColumnDefwhere
T: 'static + Iden,
pub fn new_with_type<T>(name: T, types: ColumnType) -> ColumnDefwhere
T: 'static + Iden,
Construct a table column with column type
Sourcepub fn auto_increment(&mut self) -> &mut ColumnDef
pub fn auto_increment(&mut self) -> &mut ColumnDef
Set column auto increment
Sourcepub fn unique_key(&mut self) -> &mut ColumnDef
pub fn unique_key(&mut self) -> &mut ColumnDef
Set column unique constraint
Sourcepub fn primary_key(&mut self) -> &mut ColumnDef
pub fn primary_key(&mut self) -> &mut ColumnDef
Set column as primary key
Sourcepub fn char_len(&mut self, length: u32) -> &mut ColumnDef
pub fn char_len(&mut self, length: u32) -> &mut ColumnDef
Set column type as char with custom length
Sourcepub fn string_len(&mut self, length: u32) -> &mut ColumnDef
pub fn string_len(&mut self, length: u32) -> &mut ColumnDef
Set column type as string with custom length
Sourcepub fn tiny_integer_len(&mut self, length: u32) -> &mut ColumnDef
pub fn tiny_integer_len(&mut self, length: u32) -> &mut ColumnDef
Set column type as tiny_integer with custom length
Sourcepub fn tiny_integer(&mut self) -> &mut ColumnDef
pub fn tiny_integer(&mut self) -> &mut ColumnDef
Set column type as tiny_integer
Sourcepub fn small_integer_len(&mut self, length: u32) -> &mut ColumnDef
pub fn small_integer_len(&mut self, length: u32) -> &mut ColumnDef
Set column type as small_integer with custom length
Sourcepub fn small_integer(&mut self) -> &mut ColumnDef
pub fn small_integer(&mut self) -> &mut ColumnDef
Set column type as small_integer
Sourcepub fn integer_len(&mut self, length: u32) -> &mut ColumnDef
pub fn integer_len(&mut self, length: u32) -> &mut ColumnDef
Set column type as integer with custom length
Sourcepub fn big_integer_len(&mut self, length: u32) -> &mut ColumnDef
pub fn big_integer_len(&mut self, length: u32) -> &mut ColumnDef
Set column type as big_integer with custom length
Sourcepub fn big_integer(&mut self) -> &mut ColumnDef
pub fn big_integer(&mut self) -> &mut ColumnDef
Set column type as big_integer
Sourcepub fn tiny_unsigned_len(&mut self, length: u32) -> &mut ColumnDef
pub fn tiny_unsigned_len(&mut self, length: u32) -> &mut ColumnDef
Set column type as tiny_unsigned with custom length
Sourcepub fn tiny_unsigned(&mut self) -> &mut ColumnDef
pub fn tiny_unsigned(&mut self) -> &mut ColumnDef
Set column type as tiny_unsigned
Sourcepub fn small_unsigned_len(&mut self, length: u32) -> &mut ColumnDef
pub fn small_unsigned_len(&mut self, length: u32) -> &mut ColumnDef
Set column type as small_unsigned with custom length
Sourcepub fn small_unsigned(&mut self) -> &mut ColumnDef
pub fn small_unsigned(&mut self) -> &mut ColumnDef
Set column type as small_unsigned
Sourcepub fn unsigned_len(&mut self, length: u32) -> &mut ColumnDef
pub fn unsigned_len(&mut self, length: u32) -> &mut ColumnDef
Set column type as unsigned with custom length
Sourcepub fn big_unsigned_len(&mut self, length: u32) -> &mut ColumnDef
pub fn big_unsigned_len(&mut self, length: u32) -> &mut ColumnDef
Set column type as big_unsigned with custom length
Sourcepub fn big_unsigned(&mut self) -> &mut ColumnDef
pub fn big_unsigned(&mut self) -> &mut ColumnDef
Set column type as big_unsigned
Sourcepub fn float_len(&mut self, precision: u32) -> &mut ColumnDef
pub fn float_len(&mut self, precision: u32) -> &mut ColumnDef
Set column type as float with custom precision
Sourcepub fn double_len(&mut self, precision: u32) -> &mut ColumnDef
pub fn double_len(&mut self, precision: u32) -> &mut ColumnDef
Set column type as double with custom precision
Sourcepub fn decimal_len(&mut self, precision: u32, scale: u32) -> &mut ColumnDef
pub fn decimal_len(&mut self, precision: u32, scale: u32) -> &mut ColumnDef
Set column type as decimal with custom precision and scale
Sourcepub fn date_time_len(&mut self, precision: u32) -> &mut ColumnDef
pub fn date_time_len(&mut self, precision: u32) -> &mut ColumnDef
Set column type as date_time with custom precision
Sourcepub fn interval(
&mut self,
fields: Option<PgInterval>,
precision: Option<u32>,
) -> &mut ColumnDef
pub fn interval( &mut self, fields: Option<PgInterval>, precision: Option<u32>, ) -> &mut ColumnDef
Set column type as interval type with optional fields and precision. Postgres only
use sea_query::{tests_cfg::*, *};
assert_eq!(
Table::create()
.table(Glyph::Table)
.col(
ColumnDef::new(Alias::new("I1"))
.interval(None, None)
.not_null()
)
.col(
ColumnDef::new(Alias::new("I2"))
.interval(Some(PgInterval::YearToMonth), None)
.not_null()
)
.col(
ColumnDef::new(Alias::new("I3"))
.interval(None, Some(42))
.not_null()
)
.col(
ColumnDef::new(Alias::new("I4"))
.interval(Some(PgInterval::Hour), Some(43))
.not_null()
)
.to_string(PostgresQueryBuilder),
vec![
r#"CREATE TABLE "glyph" ("#,
r#""I1" interval NOT NULL,"#,
r#""I2" interval YEAR TO MONTH NOT NULL,"#,
r#""I3" interval(42) NOT NULL,"#,
r#""I4" interval HOUR(43) NOT NULL"#,
r#")"#,
]
.join(" ")
);
Sourcepub fn timestamp_len(&mut self, precision: u32) -> &mut ColumnDef
pub fn timestamp_len(&mut self, precision: u32) -> &mut ColumnDef
Set column type as timestamp with custom precision
Sourcepub fn timestamp_with_time_zone(&mut self) -> &mut ColumnDef
pub fn timestamp_with_time_zone(&mut self) -> &mut ColumnDef
Set column type as timestamp with time zone. Postgres only
Sourcepub fn timestamp_with_time_zone_len(&mut self, precision: u32) -> &mut ColumnDef
pub fn timestamp_with_time_zone_len(&mut self, precision: u32) -> &mut ColumnDef
Set column type as timestamp with time zone plus custom precision
Sourcepub fn time_len(&mut self, precision: u32) -> &mut ColumnDef
pub fn time_len(&mut self, precision: u32) -> &mut ColumnDef
Set column type as time with custom precision
Sourcepub fn binary_len(&mut self, length: u32) -> &mut ColumnDef
pub fn binary_len(&mut self, length: u32) -> &mut ColumnDef
Set column type as binary with custom length
Sourcepub fn blob(&mut self, size: BlobSize) -> &mut ColumnDef
pub fn blob(&mut self, size: BlobSize) -> &mut ColumnDef
Set column type as blob, but when given BlobSize::Blob(size) argument, this column map to binary(size) type instead.
Sourcepub fn var_binary(&mut self, length: u32) -> &mut ColumnDef
pub fn var_binary(&mut self, length: u32) -> &mut ColumnDef
Set column type as binary with variable length
Sourcepub fn money_len(&mut self, precision: u32, scale: u32) -> &mut ColumnDef
pub fn money_len(&mut self, precision: u32, scale: u32) -> &mut ColumnDef
Set column type as money with custom precision and scale
Sourcepub fn json(&mut self) -> &mut ColumnDef
pub fn json(&mut self) -> &mut ColumnDef
Set column type as json.
On MySQL, this is equivalent to json_binary
. On MariaDB, this is equivalent to text
.
On PgSQL, this is equivalent to json
.
Sourcepub fn json_binary(&mut self) -> &mut ColumnDef
pub fn json_binary(&mut self) -> &mut ColumnDef
Set column type as json binary.
On MySQL, this is equivalent to json
. On MariaDB, this is equivalent to text
.
On PgSQL, this is equivalent to jsonb
.
Sourcepub fn custom<T>(&mut self, n: T) -> &mut ColumnDefwhere
T: 'static + Iden,
pub fn custom<T>(&mut self, n: T) -> &mut ColumnDefwhere
T: 'static + Iden,
Use a custom type on this column.
Sourcepub fn enumeration<N, S, V>(&mut self, name: N, variants: V) -> &mut ColumnDef
pub fn enumeration<N, S, V>(&mut self, name: N, variants: V) -> &mut ColumnDef
Set column type as enum.
Sourcepub fn array(&mut self, elem_type: String) -> &mut ColumnDef
pub fn array(&mut self, elem_type: String) -> &mut ColumnDef
Set column type as an array with a specified element type. This is only supported on Postgres.
Sourcepub fn cidr(&mut self) -> &mut ColumnDef
pub fn cidr(&mut self) -> &mut ColumnDef
Set columnt type as cidr. This is only supported on Postgres.
Sourcepub fn inet(&mut self) -> &mut ColumnDef
pub fn inet(&mut self) -> &mut ColumnDef
Set columnt type as inet. This is only supported on Postgres.
Sourcepub fn mac_address(&mut self) -> &mut ColumnDef
pub fn mac_address(&mut self) -> &mut ColumnDef
Set columnt type as macaddr. This is only supported on Postgres.
pub fn get_column_name(&self) -> String
pub fn get_column_type(&self) -> Option<&ColumnType>
pub fn get_column_spec(&self) -> &Vec<ColumnSpec>
pub fn take(&mut self) -> ColumnDef
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ColumnDef
impl !RefUnwindSafe for ColumnDef
impl Send for ColumnDef
impl Sync for ColumnDef
impl Unpin for ColumnDef
impl !UnwindSafe for ColumnDef
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more