logo
pub struct ColumnDef { /* private fields */ }
Expand description

Specification of a table column

Implementations

Construct a table column

Construct a table column with column type

Set column not null

Set default value of a column

Set column auto increment

Set column unique constraint

Set column as primary key

Set column type as char with custom length

Set column type as char

Set column type as string with custom length

Set column type as string

Set column type as text

Set column type as tiny_integer with custom length

Set column type as tiny_integer

Set column type as small_integer with custom length

Set column type as small_integer

Set column type as integer with custom length

Set column type as integer

Set column type as big_integer with custom length

Set column type as big_integer

Set column type as tiny_unsigned with custom length

Set column type as tiny_unsigned

Set column type as small_unsigned with custom length

Set column type as small_unsigned

Set column type as unsigned with custom length

Set column type as unsigned

Set column type as big_unsigned with custom length

Set column type as big_unsigned

Set column type as float with custom precision

Set column type as float

Set column type as double with custom precision

Set column type as double

Set column type as decimal with custom precision and scale

Set column type as decimal

Set column type as date_time with custom precision

Set column type as date_time

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(" ")
);

Set column type as timestamp with custom precision

Set column type as timestamp

Set column type as timestamp with time zone. Postgres only

Set column type as timestamp with time zone plus custom precision

Set column type as time with custom precision

Set column type as time

Set column type as date

Set column type as binary with custom length

Set column type as binary

Set column type as boolean

Set column type as money with custom precision and scale

Set column type as money

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.

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.

Set column type as uuid

Use a custom type on this column.

Set column type as enum.

Set column type as an array with a specified element type. This is only supported on Postgres.

Some extra options in custom string

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Should always be Self

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.