#[non_exhaustive]pub enum SqlValue {
Show 21 variants
Null,
Bool(bool),
TinyInt(u8),
SmallInt(i16),
Int(i32),
BigInt(i64),
Float(f32),
Double(f64),
String(String),
Binary(Bytes),
Decimal(Decimal),
Money(Decimal),
SmallMoney(Decimal),
Uuid(Uuid),
Date(NaiveDate),
Time(NaiveTime),
DateTime(NaiveDateTime),
SmallDateTime(NaiveDateTime),
DateTimeOffset(DateTime<FixedOffset>),
Xml(String),
Tvp(Box<TvpData>),
}Expand description
A SQL value that can represent any SQL Server data type.
This enum provides a type-safe way to handle SQL values that may be of various types, including NULL.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Null
NULL value.
Bool(bool)
Boolean value (BIT).
TinyInt(u8)
8-bit unsigned integer (TINYINT).
SmallInt(i16)
16-bit signed integer (SMALLINT).
Int(i32)
32-bit signed integer (INT).
BigInt(i64)
64-bit signed integer (BIGINT).
Float(f32)
32-bit floating point (REAL).
Double(f64)
64-bit floating point (FLOAT).
String(String)
String value (CHAR, VARCHAR, NCHAR, NVARCHAR, TEXT, NTEXT).
Binary(Bytes)
Binary value (BINARY, VARBINARY, IMAGE).
Decimal(Decimal)
Decimal value (DECIMAL, NUMERIC).
Money(Decimal)
Money value (MONEY — fixed-point scaled by 10_000, signed 64-bit range).
Distinct from Self::Decimal so that RPC parameter encoding can
select the MONEY wire format (type 0x6E, 8-byte scaled integer) rather
than the generic DECIMAL format. MONEY columns returned from queries
decode back to Self::Decimal — the distinction is only meaningful
on the send path.
SmallMoney(Decimal)
SmallMoney value (SMALLMONEY — fixed-point scaled by 10_000, signed 32-bit range).
Uuid(Uuid)
UUID value (UNIQUEIDENTIFIER).
Date(NaiveDate)
Date value (DATE).
Time(NaiveTime)
Time value (TIME).
DateTime(NaiveDateTime)
DateTime value (DATETIME, DATETIME2).
SmallDateTime(NaiveDateTime)
SmallDateTime value (SMALLDATETIME — minute precision, 1900-01-01..2079-06-06).
Distinct from Self::DateTime so that RPC parameter encoding can
select the SMALLDATETIME wire format (type 0x6F, 4-byte days+minutes)
rather than DATETIME2. SMALLDATETIME columns returned from queries
decode back to Self::DateTime.
DateTimeOffset(DateTime<FixedOffset>)
DateTimeOffset value (DATETIMEOFFSET).
Xml(String)
XML value (XML type).
Tvp(Box<TvpData>)
Table-Valued Parameter (TVP).
TVPs allow passing collections of structured data to SQL Server stored procedures. Boxed due to large size.
Implementations§
Trait Implementations§
Source§impl From<NaiveDateTime> for SqlValue
Available on crate feature chrono only.
impl From<NaiveDateTime> for SqlValue
chrono only.Source§fn from(v: NaiveDateTime) -> Self
fn from(v: NaiveDateTime) -> Self
Source§impl From<SmallDateTime> for SqlValue
Available on crate feature chrono only.
impl From<SmallDateTime> for SqlValue
chrono only.Source§fn from(v: SmallDateTime) -> Self
fn from(v: SmallDateTime) -> Self
Source§impl From<SmallMoney> for SqlValue
Available on crate feature decimal only.
impl From<SmallMoney> for SqlValue
decimal only.