pub enum FieldType {
Show 47 variants
BigInteger,
Integer,
SmallInteger,
TinyInt,
MediumInt,
Char(u32),
VarChar(u32),
Text,
TinyText,
MediumText,
LongText,
Date,
Time,
DateTime,
TimestampTz,
Decimal {
precision: u32,
scale: u32,
},
Float,
Double,
Real,
Boolean,
Binary,
Blob,
TinyBlob,
MediumBlob,
LongBlob,
Bytea,
Json,
JsonBinary,
Array(Box<FieldType>),
HStore,
CIText,
Int4Range,
Int8Range,
NumRange,
DateRange,
TsRange,
TsTzRange,
TsVector,
TsQuery,
Uuid,
Year,
Enum {
values: Vec<String>,
},
Set {
values: Vec<String>,
},
ForeignKey {
to_table: String,
to_field: String,
on_delete: ForeignKeyAction,
},
OneToOne {
to: String,
on_delete: ForeignKeyAction,
on_update: ForeignKeyAction,
},
ManyToMany {
to: String,
through: Option<String>,
},
Custom(String),
}Expand description
Represents database field types
Variants§
BigInteger
BigInteger variant.
Integer
Integer variant.
SmallInteger
SmallInteger variant.
TinyInt
TinyInt variant.
MediumInt
MediumInt variant.
Char(u32)
Char variant.
VarChar(u32)
VarChar variant.
Text
Text variant.
TinyText
TinyText variant.
MediumText
MediumText variant.
LongText
LongText variant.
Date
Date variant.
Time
Time variant.
DateTime
DateTime variant.
TimestampTz
TimestampTz variant.
Decimal
Decimal variant.
Float
Float variant.
Double
Double variant.
Real
Real variant.
Boolean
Boolean variant.
Binary
Binary variant.
Blob
Blob variant.
TinyBlob
TinyBlob variant.
MediumBlob
MediumBlob variant.
LongBlob
LongBlob variant.
Bytea
Bytea variant.
Json
Json variant.
JsonBinary
JsonBinary variant.
Array(Box<FieldType>)
PostgreSQL Array type with inner element type
HStore
PostgreSQL HStore key-value store
CIText
PostgreSQL case-insensitive text
Int4Range
PostgreSQL int4range (integer range)
Int8Range
PostgreSQL int8range (bigint range)
NumRange
PostgreSQL numrange (numeric range)
DateRange
PostgreSQL daterange
TsRange
PostgreSQL tsrange (timestamp range without timezone)
TsTzRange
PostgreSQL tstzrange (timestamp range with timezone)
TsVector
PostgreSQL tsvector for full-text search
TsQuery
PostgreSQL tsquery for full-text search queries
Uuid
Uuid variant.
Year
Year variant.
Enum
Enum variant.
Set
Set variant.
ForeignKey
ForeignKey relationship field
Fields
on_delete: ForeignKeyActionThe on delete.
OneToOne
OneToOne relationship field
ManyToMany
ManyToMany relationship field
Custom(String)
Custom variant.
Implementations§
Source§impl FieldType
impl FieldType
Sourcepub fn to_sql_for_dialect(&self, dialect: &SqlDialect) -> String
pub fn to_sql_for_dialect(&self, dialect: &SqlDialect) -> String
Convert FieldType to SQL string for a specific dialect
This method returns database-specific SQL types. Use this method when generating SQL for a specific database.
Sourcepub fn to_sql_string(&self) -> String
pub fn to_sql_string(&self) -> String
Convert FieldType to SQL string
This method returns generic SQL types that may not be compatible with all databases.
For database-specific SQL generation, use to_sql_for_dialect() instead.
Sourcepub fn max_length(&self) -> Option<u32>
pub fn max_length(&self) -> Option<u32>
Get max_length if this type has one
Trait Implementations§
Source§impl<'de> Deserialize<'de> for FieldType
impl<'de> Deserialize<'de> for FieldType
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<FieldType, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<FieldType, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl Serialize for FieldType
impl Serialize for FieldType
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl Eq for FieldType
impl StructuralPartialEq for FieldType
Auto Trait Implementations§
impl Freeze for FieldType
impl RefUnwindSafe for FieldType
impl Send for FieldType
impl Sync for FieldType
impl Unpin for FieldType
impl UnsafeUnpin for FieldType
impl UnwindSafe for FieldType
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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