#[repr(u8)]pub enum TypeAffinity {
Integer = 68,
Text = 66,
Blob = 65,
Real = 69,
Numeric = 67,
}Expand description
SQLite type affinity, used for column type resolution.
Variants§
Integer = 68
Column prefers integer storage. Includes INTEGER, INT, TINYINT, etc.
Text = 66
Column prefers text storage. Includes TEXT, VARCHAR, CLOB.
Blob = 65
Column has no preference. Includes BLOB or no type specified.
Real = 69
Column prefers real (float) storage. Includes REAL, DOUBLE, FLOAT.
Numeric = 67
Column prefers numeric storage. Includes NUMERIC, DECIMAL, BOOLEAN, DATE, DATETIME.
Implementations§
Source§impl TypeAffinity
impl TypeAffinity
Sourcepub fn from_type_name(type_name: &str) -> Self
pub fn from_type_name(type_name: &str) -> Self
Determine the type affinity for a declared column type name.
Uses SQLite’s first-match rule (§3.1 of datatype3.html):
- Contains “INT” → INTEGER
- Contains “CHAR”, “CLOB”, or “TEXT” → TEXT
- Contains “BLOB” or is empty → BLOB
- Contains “REAL”, “FLOA”, or “DOUB” → REAL
- Otherwise → NUMERIC
Sourcepub fn comparison_affinity(left: Self, right: Self) -> Option<Self>
pub fn comparison_affinity(left: Self, right: Self) -> Option<Self>
Determine the affinity to apply for a comparison between two operands.
Returns Some(affinity) if one side needs coercion, None if no
coercion is needed. The returned affinity should be applied to the
operand that needs conversion.
Rules (§3.2 of datatype3.html):
- If one operand is INTEGER/REAL/NUMERIC and the other is TEXT/BLOB, apply numeric affinity to the TEXT/BLOB side.
- If one operand is TEXT and the other is BLOB (no numeric involved), apply TEXT affinity to the BLOB side.
- Same affinity or both BLOB → no coercion.
Trait Implementations§
Source§impl Clone for TypeAffinity
impl Clone for TypeAffinity
Source§fn clone(&self) -> TypeAffinity
fn clone(&self) -> TypeAffinity
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more