#[non_exhaustive]pub enum DefaultValue {
Bool(bool),
Integer(i64),
Float(f64),
String(String),
}Expand description
A column default value that can be a boolean, integer, float, or SQL expression string.
In JSON model files the "default" field accepts any of these forms:
true/false— boolean literal.0,42— integer literal.0.0,1.5— floating-point literal."'pending'"— SQL string literal (note the inner single quotes)."NOW()"— SQL function call (no surrounding quotes).
Use DefaultValue::to_sql to convert to the SQL representation for DDL generation.
StringOrBool is a backwards-compatibility alias for this type.
This enum is #[non_exhaustive]: new variants may be added in future releases.
Downstream match expressions should include a wildcard arm.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Bool(bool)
A boolean default (true or false).
Integer(i64)
An integer default value.
Float(f64)
A floating-point default value.
String(String)
A SQL expression or string literal default (e.g. "'pending'" or "NOW()").
Implementations§
Source§impl DefaultValue
impl DefaultValue
Sourcepub fn to_sql(&self) -> String
pub fn to_sql(&self) -> String
Convert to SQL string representation Empty strings are converted to ‘’ (SQL empty string literal)
Sourcepub fn is_string(&self) -> bool
pub fn is_string(&self) -> bool
Check if this is a string type (needs quoting for certain column types)
Sourcepub fn is_empty_string(&self) -> bool
pub fn is_empty_string(&self) -> bool
Check if this is an empty string
Trait Implementations§
Source§impl Clone for DefaultValue
impl Clone for DefaultValue
Source§impl Debug for DefaultValue
impl Debug for DefaultValue
Source§impl<'de> Deserialize<'de> for DefaultValue
impl<'de> Deserialize<'de> for DefaultValue
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for DefaultValue
Source§impl From<&str> for DefaultValue
impl From<&str> for DefaultValue
Source§impl From<String> for DefaultValue
impl From<String> for DefaultValue
Source§impl From<bool> for DefaultValue
impl From<bool> for DefaultValue
Source§impl From<f64> for DefaultValue
impl From<f64> for DefaultValue
Source§impl From<i32> for DefaultValue
impl From<i32> for DefaultValue
Source§impl From<i64> for DefaultValue
impl From<i64> for DefaultValue
Source§impl JsonSchema for DefaultValue
impl JsonSchema for DefaultValue
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
$ref keyword. Read moreSource§impl PartialEq for DefaultValue
impl PartialEq for DefaultValue
Source§impl Serialize for DefaultValue
impl Serialize for DefaultValue
impl StructuralPartialEq for DefaultValue
Auto Trait Implementations§
impl Freeze for DefaultValue
impl RefUnwindSafe for DefaultValue
impl Send for DefaultValue
impl Sync for DefaultValue
impl Unpin for DefaultValue
impl UnsafeUnpin for DefaultValue
impl UnwindSafe for DefaultValue
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,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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