Skip to main content

DEFAULT

Constant DEFAULT 

Source
pub const DEFAULT: ColumnMarker;
Expand description

Adds a DEFAULT clause to the column.

Takes a literal, CURRENT_TIME, CURRENT_DATE, CURRENT_TIMESTAMP, or an SQL function call. Expressions other than literals and the CURRENT_* keywords are wrapped in parentheses, as SQLite requires.

ยงExamples

#[column(default = 0)]
count: i32,

#[column(default = "guest")]
role: String,

#[column(default = CURRENT_TIMESTAMP)]
created_at: String,

#[column(default = strftime("%s", "now"))]
created_at_unix: i64,

For application-generated values such as UUIDs, use DEFAULT_FN instead.

See: https://sqlite.org/lang_createtable.html#the_default_clause