Cleanup before merging.
This commit is contained in:
parent
179c8c7908
commit
c46a13f9e1
2 changed files with 22 additions and 21 deletions
|
@ -284,16 +284,16 @@ impl From<i32> for TypedValue {
|
||||||
/// Type safe representation of the possible return values from SQLite's `typeof`
|
/// Type safe representation of the possible return values from SQLite's `typeof`
|
||||||
#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialOrd, PartialEq)]
|
#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialOrd, PartialEq)]
|
||||||
pub enum SQLTypeAffinity {
|
pub enum SQLTypeAffinity {
|
||||||
Null, // "null"
|
Null, // "null"
|
||||||
Integer, // "integer"
|
Integer, // "integer"
|
||||||
Real, // "real"
|
Real, // "real"
|
||||||
Text, // "text"
|
Text, // "text"
|
||||||
Blob, // "blob"
|
Blob, // "blob"
|
||||||
}
|
}
|
||||||
|
|
||||||
// Put this here rather than in `db` simply because it's widely needed.
|
// Put this here rather than in `db` simply because it's widely needed.
|
||||||
pub trait SQLValueType {
|
pub trait SQLValueType {
|
||||||
fn value_type_tag(&self) -> i32;
|
fn value_type_tag(&self) -> ValueTypeTag;
|
||||||
fn accommodates_integer(&self, int: i64) -> bool;
|
fn accommodates_integer(&self, int: i64) -> bool;
|
||||||
|
|
||||||
/// Return a pair of the ValueTypeTag for this value type, and the SQLTypeAffinity required
|
/// Return a pair of the ValueTypeTag for this value type, and the SQLTypeAffinity required
|
||||||
|
@ -306,7 +306,23 @@ pub trait SQLValueType {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SQLValueType for ValueType {
|
impl SQLValueType for ValueType {
|
||||||
fn value_type_tag(&self) -> i32 {
|
fn sql_representation(&self) -> (ValueTypeTag, Option<SQLTypeAffinity>) {
|
||||||
|
match *self {
|
||||||
|
ValueType::Ref => (0, None),
|
||||||
|
ValueType::Boolean => (1, None),
|
||||||
|
ValueType::Instant => (4, None),
|
||||||
|
|
||||||
|
// SQLite distinguishes integral from decimal types, allowing long and double to share a tag.
|
||||||
|
ValueType::Long => (5, Some(SQLTypeAffinity::Integer)),
|
||||||
|
ValueType::Double => (5, Some(SQLTypeAffinity::Real)),
|
||||||
|
ValueType::String => (10, None),
|
||||||
|
ValueType::Uuid => (11, None),
|
||||||
|
ValueType::Keyword => (13, None),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
fn value_type_tag(&self) -> ValueTypeTag {
|
||||||
self.sql_representation().0
|
self.sql_representation().0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -334,20 +350,6 @@ impl SQLValueType for ValueType {
|
||||||
Uuid => false,
|
Uuid => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn sql_representation(&self) -> (ValueTypeTag, Option<SQLTypeAffinity>) {
|
|
||||||
match *self {
|
|
||||||
ValueType::Ref => (0, None),
|
|
||||||
ValueType::Boolean => (1, None),
|
|
||||||
ValueType::Instant => (4, None),
|
|
||||||
// SQLite distinguishes integral from decimal types, allowing long and double to share a tag.
|
|
||||||
ValueType::Long => (5, Some(SQLTypeAffinity::Integer)),
|
|
||||||
ValueType::Double => (5, Some(SQLTypeAffinity::Real)),
|
|
||||||
ValueType::String => (10, None),
|
|
||||||
ValueType::Uuid => (11, None),
|
|
||||||
ValueType::Keyword => (13, None),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
trait EnumSetExtensions<T: enum_set::CLike + Clone> {
|
trait EnumSetExtensions<T: enum_set::CLike + Clone> {
|
||||||
|
|
|
@ -15,7 +15,6 @@ extern crate mentat;
|
||||||
extern crate mentat_core;
|
extern crate mentat_core;
|
||||||
extern crate mentat_db;
|
extern crate mentat_db;
|
||||||
extern crate mentat_query_algebrizer; // For errors.
|
extern crate mentat_query_algebrizer; // For errors.
|
||||||
extern crate rusqlite;
|
|
||||||
|
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue