Cleanup before merging.

This commit is contained in:
Richard Newman 2018-01-29 14:09:42 -08:00
parent 179c8c7908
commit c46a13f9e1
2 changed files with 22 additions and 21 deletions

View file

@ -293,7 +293,7 @@ pub enum SQLTypeAffinity {
// 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> {

View file

@ -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;