DataType

Enum DataType 

Source
pub enum DataType {
Show 23 variants Integer, Smallint, Bigint, Unsigned, Numeric { precision: u8, scale: u8, }, Decimal { precision: u8, scale: u8, }, Float { precision: u8, }, Real, DoublePrecision, Character { length: usize, }, Varchar { max_length: Option<usize>, }, CharacterLargeObject, Name, Boolean, Date, Time { with_timezone: bool, }, Timestamp { with_timezone: bool, }, Interval { start_field: IntervalField, end_field: Option<IntervalField>, }, BinaryLargeObject, Bit { length: Option<usize>, }, Vector { dimensions: u32, }, UserDefined { type_name: String, }, Null,
}
Expand description

SQL:1999 Data Types

Represents the type of a column or expression in SQL.

Variants§

§

Integer

§

Smallint

§

Bigint

§

Unsigned

§

Numeric

Fields

§precision: u8
§scale: u8
§

Decimal

Fields

§precision: u8
§scale: u8
§

Float

Fields

§precision: u8
§

Real

§

DoublePrecision

§

Character

Fields

§length: usize
§

Varchar

Fields

§max_length: Option<usize>
§

CharacterLargeObject

§

Name

§

Boolean

§

Date

§

Time

Fields

§with_timezone: bool
§

Timestamp

Fields

§with_timezone: bool
§

Interval

Fields

§start_field: IntervalField
§

BinaryLargeObject

§

Bit

Fields

§length: Option<usize>
§

Vector

Fields

§dimensions: u32
§

UserDefined

Fields

§type_name: String
§

Null

Implementations§

Source§

impl DataType

Source

pub fn coerce_to_common(&self, other: &DataType) -> Option<DataType>

Coerces two types to their common type according to SQL:1999 rules

Returns the result type that should be used when combining values of the two input types, or None if no implicit coercion exists.

Based on SQL:1999 Section 9.5 (Result of data type combinations).

Source

pub fn is_compatible_with(&self, other: &DataType) -> bool

Check if this type is compatible with another type for operations

This now uses SQL:1999 type coercion rules. Types are compatible if they can be implicitly coerced to a common type.

Source

pub fn estimated_size_bytes(&self) -> usize

Returns an estimated size in bytes for values of this type.

This is used for adaptive morsel sizing to maintain cache efficiency. Estimates are conservative (may overestimate) to ensure cache fitting.

Returns the estimated size in bytes for a single value of this type, including any overhead from the SqlValue enum representation.

Source

pub fn sqlite_affinity(&self) -> TypeAffinity

Returns the SQLite type affinity for this data type.

SQLite determines affinity based on the declared type name:

  1. If the type contains “INT” → INTEGER affinity
  2. If the type contains “CHAR”, “CLOB”, or “TEXT” → TEXT affinity
  3. If the type contains “BLOB” or has no type → BLOB/NONE affinity
  4. If the type contains “REAL”, “FLOA”, or “DOUB” → REAL affinity
  5. Otherwise → NUMERIC affinity

See: https://www.sqlite.org/datatype3.html#type_affinity

Trait Implementations§

Source§

impl Clone for DataType

Source§

fn clone(&self) -> DataType

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for DataType

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for DataType

Source§

fn eq(&self, other: &DataType) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for DataType

Source§

impl StructuralPartialEq for DataType

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

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

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.