Update some dependencies. (#492) r=etoop
* Update some dependencies. * Update rusqlite to 0.12. * Update error-chain to a forked version that implements Sync. * Fix some compiler warnings. * Remove unused imports in tests. * Parse errors no longer naturally print with the expected symbol.
This commit is contained in:
parent
c15973f269
commit
c600152d78
24 changed files with 84 additions and 86 deletions
|
@ -17,12 +17,12 @@ members = []
|
||||||
rustc_version = "0.1.7"
|
rustc_version = "0.1.7"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
chrono = "0.3"
|
chrono = "0.4"
|
||||||
error-chain = "0.8.1"
|
error-chain = { git = "https://github.com/rnewman/error-chain", branch = "rnewman/sync" }
|
||||||
time = "0.1"
|
time = "0.1"
|
||||||
|
|
||||||
[dependencies.rusqlite]
|
[dependencies.rusqlite]
|
||||||
version = "0.11"
|
version = "0.12"
|
||||||
# System sqlite might be very old.
|
# System sqlite might be very old.
|
||||||
features = ["bundled", "limits"]
|
features = ["bundled", "limits"]
|
||||||
|
|
||||||
|
|
|
@ -5,9 +5,9 @@ workspace = ".."
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
enum-set = { git = "https://github.com/rnewman/enum-set" }
|
enum-set = { git = "https://github.com/rnewman/enum-set" }
|
||||||
lazy_static = "0.2.2"
|
lazy_static = "0.2"
|
||||||
num = "0.1.35"
|
num = "0.1"
|
||||||
ordered-float = "0.4.0"
|
ordered-float = "0.5"
|
||||||
|
|
||||||
[dependencies.edn]
|
[dependencies.edn]
|
||||||
path = "../edn"
|
path = "../edn"
|
||||||
|
|
|
@ -37,7 +37,7 @@ pub use edn::{
|
||||||
DateTime,
|
DateTime,
|
||||||
FromMicros,
|
FromMicros,
|
||||||
ToMicros,
|
ToMicros,
|
||||||
UTC,
|
Utc,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Core types defining a Mentat knowledge base.
|
/// Core types defining a Mentat knowledge base.
|
||||||
|
@ -130,7 +130,7 @@ pub enum TypedValue {
|
||||||
Boolean(bool),
|
Boolean(bool),
|
||||||
Long(i64),
|
Long(i64),
|
||||||
Double(OrderedFloat<f64>),
|
Double(OrderedFloat<f64>),
|
||||||
Instant(DateTime<UTC>),
|
Instant(DateTime<Utc>),
|
||||||
// TODO: &str throughout?
|
// TODO: &str throughout?
|
||||||
String(Rc<String>),
|
String(Rc<String>),
|
||||||
Keyword(Rc<NamespacedKeyword>),
|
Keyword(Rc<NamespacedKeyword>),
|
||||||
|
@ -178,7 +178,7 @@ impl TypedValue {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn current_instant() -> TypedValue {
|
pub fn current_instant() -> TypedValue {
|
||||||
TypedValue::Instant(UTC::now())
|
TypedValue::Instant(Utc::now())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,14 +4,14 @@ version = "0.0.1"
|
||||||
workspace = ".."
|
workspace = ".."
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
error-chain = "0.8.1"
|
error-chain = { git = "https://github.com/rnewman/error-chain", branch = "rnewman/sync" }
|
||||||
itertools = "0.5"
|
itertools = "0.7"
|
||||||
lazy_static = "0.2"
|
lazy_static = "0.2"
|
||||||
ordered-float = "0.4"
|
ordered-float = "0.5"
|
||||||
time = "0.1"
|
time = "0.1"
|
||||||
|
|
||||||
[dependencies.rusqlite]
|
[dependencies.rusqlite]
|
||||||
version = "0.11"
|
version = "0.12"
|
||||||
# System sqlite might be very old.
|
# System sqlite might be very old.
|
||||||
features = ["bundled", "limits"]
|
features = ["bundled", "limits"]
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@ use bootstrap;
|
||||||
|
|
||||||
use edn::{
|
use edn::{
|
||||||
DateTime,
|
DateTime,
|
||||||
UTC,
|
Utc,
|
||||||
Uuid,
|
Uuid,
|
||||||
Value,
|
Value,
|
||||||
};
|
};
|
||||||
|
@ -358,7 +358,7 @@ impl TypedSQLValue for TypedValue {
|
||||||
(1, rusqlite::types::Value::Integer(x)) => Ok(TypedValue::Boolean(0 != x)),
|
(1, rusqlite::types::Value::Integer(x)) => Ok(TypedValue::Boolean(0 != x)),
|
||||||
|
|
||||||
// Negative integers are simply times before 1970.
|
// Negative integers are simply times before 1970.
|
||||||
(4, rusqlite::types::Value::Integer(x)) => Ok(TypedValue::Instant(DateTime::<UTC>::from_micros(x))),
|
(4, rusqlite::types::Value::Integer(x)) => Ok(TypedValue::Instant(DateTime::<Utc>::from_micros(x))),
|
||||||
|
|
||||||
// SQLite distinguishes integral from decimal types, allowing long and double to
|
// SQLite distinguishes integral from decimal types, allowing long and double to
|
||||||
// share a tag.
|
// share a tag.
|
||||||
|
@ -1076,7 +1076,7 @@ impl PartitionMapping for PartitionMap {
|
||||||
/// Allocate `n` fresh entids in the given `partition`.
|
/// Allocate `n` fresh entids in the given `partition`.
|
||||||
fn allocate_entids<S: ?Sized + Ord + Display>(&mut self, partition: &S, n: usize) -> Range<i64> where String: Borrow<S> {
|
fn allocate_entids<S: ?Sized + Ord + Display>(&mut self, partition: &S, n: usize) -> Range<i64> where String: Borrow<S> {
|
||||||
match self.get_mut(partition) {
|
match self.get_mut(partition) {
|
||||||
Some(mut partition) => {
|
Some(partition) => {
|
||||||
let idx = partition.index;
|
let idx = partition.index;
|
||||||
partition.index += n as i64;
|
partition.index += n as i64;
|
||||||
idx..partition.index
|
idx..partition.index
|
||||||
|
|
|
@ -30,7 +30,7 @@ use itertools::Itertools;
|
||||||
|
|
||||||
use mentat_core::{
|
use mentat_core::{
|
||||||
DateTime,
|
DateTime,
|
||||||
UTC,
|
Utc,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub use errors::{Error, ErrorKind, ResultExt, Result};
|
pub use errors::{Error, ErrorKind, ResultExt, Result};
|
||||||
|
@ -97,6 +97,6 @@ pub fn repeat_values(values_per_tuple: usize, tuples: usize) -> String {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return the current time as a UTC `DateTime` instance.
|
/// Return the current time as a UTC `DateTime` instance.
|
||||||
pub fn now() -> DateTime<UTC> {
|
pub fn now() -> DateTime<Utc> {
|
||||||
UTC::now()
|
Utc::now()
|
||||||
}
|
}
|
||||||
|
|
14
db/src/tx.rs
14
db/src/tx.rs
|
@ -83,7 +83,7 @@ use mentat_core::util::Either;
|
||||||
use mentat_core::{
|
use mentat_core::{
|
||||||
DateTime,
|
DateTime,
|
||||||
Schema,
|
Schema,
|
||||||
UTC,
|
Utc,
|
||||||
attribute,
|
attribute,
|
||||||
intern_set,
|
intern_set,
|
||||||
};
|
};
|
||||||
|
@ -139,7 +139,7 @@ pub struct Tx<'conn, 'a> {
|
||||||
tx_id: Entid,
|
tx_id: Entid,
|
||||||
|
|
||||||
/// The timestamp when the transaction began to be committed.
|
/// The timestamp when the transaction began to be committed.
|
||||||
tx_instant: DateTime<UTC>,
|
tx_instant: DateTime<Utc>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'conn, 'a> Tx<'conn, 'a> {
|
impl<'conn, 'a> Tx<'conn, 'a> {
|
||||||
|
@ -149,7 +149,7 @@ impl<'conn, 'a> Tx<'conn, 'a> {
|
||||||
schema_for_mutation: &'a Schema,
|
schema_for_mutation: &'a Schema,
|
||||||
schema: &'a Schema,
|
schema: &'a Schema,
|
||||||
tx_id: Entid,
|
tx_id: Entid,
|
||||||
tx_instant: DateTime<UTC>) -> Tx<'conn, 'a> {
|
tx_instant: DateTime<Utc>) -> Tx<'conn, 'a> {
|
||||||
Tx {
|
Tx {
|
||||||
store: store,
|
store: store,
|
||||||
partition_map: partition_map,
|
partition_map: partition_map,
|
||||||
|
@ -590,16 +590,16 @@ impl<'conn, 'a> Tx<'conn, 'a> {
|
||||||
|
|
||||||
{ // TODO: Don't use this block to scope borrowing the schema; instead, extract a helper function.
|
{ // TODO: Don't use this block to scope borrowing the schema; instead, extract a helper function.
|
||||||
|
|
||||||
/// Assertions that are :db.cardinality/one and not :db.fulltext.
|
// Assertions that are :db.cardinality/one and not :db.fulltext.
|
||||||
let mut non_fts_one: Vec<db::ReducedEntity> = vec![];
|
let mut non_fts_one: Vec<db::ReducedEntity> = vec![];
|
||||||
|
|
||||||
/// Assertions that are :db.cardinality/many and not :db.fulltext.
|
// Assertions that are :db.cardinality/many and not :db.fulltext.
|
||||||
let mut non_fts_many: Vec<db::ReducedEntity> = vec![];
|
let mut non_fts_many: Vec<db::ReducedEntity> = vec![];
|
||||||
|
|
||||||
/// Assertions that are :db.cardinality/one and :db.fulltext.
|
// Assertions that are :db.cardinality/one and :db.fulltext.
|
||||||
let mut fts_one: Vec<db::ReducedEntity> = vec![];
|
let mut fts_one: Vec<db::ReducedEntity> = vec![];
|
||||||
|
|
||||||
/// Assertions that are :db.cardinality/many and :db.fulltext.
|
// Assertions that are :db.cardinality/many and :db.fulltext.
|
||||||
let mut fts_many: Vec<db::ReducedEntity> = vec![];
|
let mut fts_many: Vec<db::ReducedEntity> = vec![];
|
||||||
|
|
||||||
// We need to ensure that callers can't blindly transact entities that haven't been
|
// We need to ensure that callers can't blindly transact entities that haven't been
|
||||||
|
|
|
@ -23,7 +23,7 @@ pub use self::mentat_core::{
|
||||||
Attribute,
|
Attribute,
|
||||||
AttributeBitFlags,
|
AttributeBitFlags,
|
||||||
Schema,
|
Schema,
|
||||||
UTC,
|
Utc,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Represents one partition of the entid space.
|
/// Represents one partition of the entid space.
|
||||||
|
@ -90,7 +90,7 @@ pub struct TxReport {
|
||||||
pub tx_id: Entid,
|
pub tx_id: Entid,
|
||||||
|
|
||||||
/// The timestamp when the transaction began to be committed.
|
/// The timestamp when the transaction began to be committed.
|
||||||
pub tx_instant: DateTime<UTC>,
|
pub tx_instant: DateTime<Utc>,
|
||||||
|
|
||||||
/// A map from string literal tempid to resolved or allocated entid.
|
/// A map from string literal tempid to resolved or allocated entid.
|
||||||
///
|
///
|
||||||
|
|
|
@ -11,10 +11,10 @@ build = "build.rs"
|
||||||
readme = "./README.md"
|
readme = "./README.md"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
chrono = "0.3"
|
chrono = "0.4"
|
||||||
itertools = "0.5"
|
itertools = "0.7"
|
||||||
num = "0.1"
|
num = "0.1"
|
||||||
ordered-float = "0.4"
|
ordered-float = "0.5"
|
||||||
pretty = "0.2"
|
pretty = "0.2"
|
||||||
uuid = "0.5"
|
uuid = "0.5"
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@ use std::f64::{NAN, INFINITY, NEG_INFINITY};
|
||||||
use chrono::{
|
use chrono::{
|
||||||
DateTime,
|
DateTime,
|
||||||
TimeZone,
|
TimeZone,
|
||||||
UTC
|
Utc
|
||||||
};
|
};
|
||||||
use num::BigInt;
|
use num::BigInt;
|
||||||
use ordered_float::OrderedFloat;
|
use ordered_float::OrderedFloat;
|
||||||
|
@ -152,7 +152,7 @@ pub text -> ValueAndSpan =
|
||||||
// RFC 3339 timestamps. #inst "1985-04-12T23:20:50.52Z"
|
// RFC 3339 timestamps. #inst "1985-04-12T23:20:50.52Z"
|
||||||
// We accept an arbitrary depth of decimals.
|
// We accept an arbitrary depth of decimals.
|
||||||
// Note that we discard the timezone information -- all times are translated to UTC.
|
// Note that we discard the timezone information -- all times are translated to UTC.
|
||||||
pub inst_string -> DateTime<UTC> =
|
pub inst_string -> DateTime<Utc> =
|
||||||
"#inst" whitespace+ "\"" d:$( [0-9]*<4> "-" [0-2][0-9] "-" [0-3][0-9]
|
"#inst" whitespace+ "\"" d:$( [0-9]*<4> "-" [0-2][0-9] "-" [0-3][0-9]
|
||||||
"T"
|
"T"
|
||||||
[0-2][0-9] ":" [0-5][0-9] ":" [0-6][0-9]
|
[0-2][0-9] ":" [0-5][0-9] ":" [0-6][0-9]
|
||||||
|
@ -161,24 +161,24 @@ pub inst_string -> DateTime<UTC> =
|
||||||
)
|
)
|
||||||
"\"" {?
|
"\"" {?
|
||||||
DateTime::parse_from_rfc3339(d)
|
DateTime::parse_from_rfc3339(d)
|
||||||
.map(|t| t.with_timezone(&UTC))
|
.map(|t| t.with_timezone(&Utc))
|
||||||
.map_err(|_| "invalid datetime") // Oh, rustpeg.
|
.map_err(|_| "invalid datetime") // Oh, rustpeg.
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inst_micros -> DateTime<UTC> =
|
pub inst_micros -> DateTime<Utc> =
|
||||||
"#instmicros" whitespace+ d:$( digit+ ) {
|
"#instmicros" whitespace+ d:$( digit+ ) {
|
||||||
let micros = d.parse::<i64>().unwrap();
|
let micros = d.parse::<i64>().unwrap();
|
||||||
let seconds: i64 = micros / 1000000;
|
let seconds: i64 = micros / 1000000;
|
||||||
let nanos: u32 = ((micros % 1000000).abs() as u32) * 1000;
|
let nanos: u32 = ((micros % 1000000).abs() as u32) * 1000;
|
||||||
UTC.timestamp(seconds, nanos)
|
Utc.timestamp(seconds, nanos)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inst_millis -> DateTime<UTC> =
|
pub inst_millis -> DateTime<Utc> =
|
||||||
"#instmillis" whitespace+ d:$( digit+ ) {
|
"#instmillis" whitespace+ d:$( digit+ ) {
|
||||||
let millis = d.parse::<i64>().unwrap();
|
let millis = d.parse::<i64>().unwrap();
|
||||||
let seconds: i64 = millis / 1000;
|
let seconds: i64 = millis / 1000;
|
||||||
let nanos: u32 = ((millis % 1000).abs() as u32) * 1000000;
|
let nanos: u32 = ((millis % 1000).abs() as u32) * 1000000;
|
||||||
UTC.timestamp(seconds, nanos)
|
Utc.timestamp(seconds, nanos)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inst -> ValueAndSpan =
|
pub inst -> ValueAndSpan =
|
||||||
|
|
|
@ -26,7 +26,7 @@ pub mod parse {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Re-export the types we use.
|
// Re-export the types we use.
|
||||||
pub use chrono::{DateTime, UTC};
|
pub use chrono::{DateTime, Utc};
|
||||||
pub use num::BigInt;
|
pub use num::BigInt;
|
||||||
pub use ordered_float::OrderedFloat;
|
pub use ordered_float::OrderedFloat;
|
||||||
pub use uuid::Uuid;
|
pub use uuid::Uuid;
|
||||||
|
|
|
@ -17,8 +17,8 @@ use std::f64;
|
||||||
|
|
||||||
use chrono::{
|
use chrono::{
|
||||||
DateTime,
|
DateTime,
|
||||||
TimeZone, // For UTC::timestamp. The compiler incorrectly complains that this is unused.
|
TimeZone, // For Utc::timestamp. The compiler incorrectly complains that this is unused.
|
||||||
UTC,
|
Utc,
|
||||||
};
|
};
|
||||||
use num::BigInt;
|
use num::BigInt;
|
||||||
use ordered_float::OrderedFloat;
|
use ordered_float::OrderedFloat;
|
||||||
|
@ -32,7 +32,7 @@ pub enum Value {
|
||||||
Nil,
|
Nil,
|
||||||
Boolean(bool),
|
Boolean(bool),
|
||||||
Integer(i64),
|
Integer(i64),
|
||||||
Instant(DateTime<UTC>),
|
Instant(DateTime<Utc>),
|
||||||
BigInteger(BigInt),
|
BigInteger(BigInt),
|
||||||
Float(OrderedFloat<f64>),
|
Float(OrderedFloat<f64>),
|
||||||
Text(String),
|
Text(String),
|
||||||
|
@ -61,7 +61,7 @@ pub enum SpannedValue {
|
||||||
Nil,
|
Nil,
|
||||||
Boolean(bool),
|
Boolean(bool),
|
||||||
Integer(i64),
|
Integer(i64),
|
||||||
Instant(DateTime<UTC>),
|
Instant(DateTime<Utc>),
|
||||||
BigInteger(BigInt),
|
BigInteger(BigInt),
|
||||||
Float(OrderedFloat<f64>),
|
Float(OrderedFloat<f64>),
|
||||||
Text(String),
|
Text(String),
|
||||||
|
@ -315,7 +315,7 @@ macro_rules! def_common_value_methods {
|
||||||
|
|
||||||
def_as!(as_boolean, $t::Boolean, bool,);
|
def_as!(as_boolean, $t::Boolean, bool,);
|
||||||
def_as!(as_integer, $t::Integer, i64,);
|
def_as!(as_integer, $t::Integer, i64,);
|
||||||
def_as!(as_instant, $t::Instant, DateTime<UTC>,);
|
def_as!(as_instant, $t::Instant, DateTime<Utc>,);
|
||||||
def_as!(as_float, $t::Float, f64, |v: OrderedFloat<f64>| v.into_inner());
|
def_as!(as_float, $t::Float, f64, |v: OrderedFloat<f64>| v.into_inner());
|
||||||
|
|
||||||
def_as_ref!(as_big_integer, $t::BigInteger, BigInt);
|
def_as_ref!(as_big_integer, $t::BigInteger, BigInt);
|
||||||
|
@ -333,7 +333,7 @@ macro_rules! def_common_value_methods {
|
||||||
|
|
||||||
def_into!(into_boolean, $t::Boolean, bool,);
|
def_into!(into_boolean, $t::Boolean, bool,);
|
||||||
def_into!(into_integer, $t::Integer, i64,);
|
def_into!(into_integer, $t::Integer, i64,);
|
||||||
def_into!(into_instant, $t::Instant, DateTime<UTC>,);
|
def_into!(into_instant, $t::Instant, DateTime<Utc>,);
|
||||||
def_into!(into_big_integer, $t::BigInteger, BigInt,);
|
def_into!(into_big_integer, $t::BigInteger, BigInt,);
|
||||||
def_into!(into_ordered_float, $t::Float, OrderedFloat<f64>,);
|
def_into!(into_ordered_float, $t::Float, OrderedFloat<f64>,);
|
||||||
def_into!(into_float, $t::Float, f64, |v: OrderedFloat<f64>| v.into_inner());
|
def_into!(into_float, $t::Float, f64, |v: OrderedFloat<f64>| v.into_inner());
|
||||||
|
@ -561,9 +561,9 @@ pub trait FromMicros {
|
||||||
fn from_micros(ts: i64) -> Self;
|
fn from_micros(ts: i64) -> Self;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FromMicros for DateTime<UTC> {
|
impl FromMicros for DateTime<Utc> {
|
||||||
fn from_micros(ts: i64) -> Self {
|
fn from_micros(ts: i64) -> Self {
|
||||||
UTC.timestamp(ts / 1_000_000, ((ts % 1_000_000).abs() as u32) * 1_000)
|
Utc.timestamp(ts / 1_000_000, ((ts % 1_000_000).abs() as u32) * 1_000)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -571,7 +571,7 @@ pub trait ToMicros {
|
||||||
fn to_micros(&self) -> i64;
|
fn to_micros(&self) -> i64;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ToMicros for DateTime<UTC> {
|
impl ToMicros for DateTime<Utc> {
|
||||||
fn to_micros(&self) -> i64 {
|
fn to_micros(&self) -> i64 {
|
||||||
let major: i64 = self.timestamp() * 1_000_000;
|
let major: i64 = self.timestamp() * 1_000_000;
|
||||||
let minor: i64 = self.timestamp_subsec_micros() as i64;
|
let minor: i64 = self.timestamp_subsec_micros() as i64;
|
||||||
|
@ -596,7 +596,7 @@ mod test {
|
||||||
|
|
||||||
use chrono::{
|
use chrono::{
|
||||||
DateTime,
|
DateTime,
|
||||||
UTC,
|
Utc,
|
||||||
};
|
};
|
||||||
use num::BigInt;
|
use num::BigInt;
|
||||||
use ordered_float::OrderedFloat;
|
use ordered_float::OrderedFloat;
|
||||||
|
@ -604,7 +604,7 @@ mod test {
|
||||||
#[test]
|
#[test]
|
||||||
fn test_micros_roundtrip() {
|
fn test_micros_roundtrip() {
|
||||||
let ts_micros: i64 = 1493399581314000;
|
let ts_micros: i64 = 1493399581314000;
|
||||||
let dt = DateTime::<UTC>::from_micros(ts_micros);
|
let dt = DateTime::<Utc>::from_micros(ts_micros);
|
||||||
assert_eq!(dt.to_micros(), ts_micros);
|
assert_eq!(dt.to_micros(), ts_micros);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,7 @@ use edn::types::{
|
||||||
};
|
};
|
||||||
use chrono::{
|
use chrono::{
|
||||||
TimeZone,
|
TimeZone,
|
||||||
UTC,
|
Utc,
|
||||||
};
|
};
|
||||||
use edn::symbols;
|
use edn::symbols;
|
||||||
use edn::utils;
|
use edn::utils;
|
||||||
|
@ -425,10 +425,10 @@ fn test_value() {
|
||||||
assert_eq!(value("{1 2}").unwrap(), Map(BTreeMap::from_iter(vec![(Integer(1), Integer(2))])));
|
assert_eq!(value("{1 2}").unwrap(), Map(BTreeMap::from_iter(vec![(Integer(1), Integer(2))])));
|
||||||
assert_eq!(value("#uuid \"e43c6f3e-3123-49b7-8098-9b47a7bc0fa4\"").unwrap(),
|
assert_eq!(value("#uuid \"e43c6f3e-3123-49b7-8098-9b47a7bc0fa4\"").unwrap(),
|
||||||
Uuid(uuid::Uuid::parse_str("e43c6f3e-3123-49b7-8098-9b47a7bc0fa4").unwrap()));
|
Uuid(uuid::Uuid::parse_str("e43c6f3e-3123-49b7-8098-9b47a7bc0fa4").unwrap()));
|
||||||
assert_eq!(value("#instmillis 1493410985187").unwrap(), Instant(UTC.timestamp(1493410985, 187000000)));
|
assert_eq!(value("#instmillis 1493410985187").unwrap(), Instant(Utc.timestamp(1493410985, 187000000)));
|
||||||
assert_eq!(value("#instmicros 1493410985187123").unwrap(), Instant(UTC.timestamp(1493410985, 187123000)));
|
assert_eq!(value("#instmicros 1493410985187123").unwrap(), Instant(Utc.timestamp(1493410985, 187123000)));
|
||||||
assert_eq!(value("#inst \"2017-04-28T20:23:05.187Z\"").unwrap(),
|
assert_eq!(value("#inst \"2017-04-28T20:23:05.187Z\"").unwrap(),
|
||||||
Instant(UTC.timestamp(1493410985, 187000000)));
|
Instant(Utc.timestamp(1493410985, 187000000)));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
@ -6,7 +6,7 @@ workspace = ".."
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
combine = "2.3.2"
|
combine = "2.3.2"
|
||||||
itertools = "0.5.9"
|
itertools = "0.7"
|
||||||
|
|
||||||
[dependencies.edn]
|
[dependencies.edn]
|
||||||
path = "../edn"
|
path = "../edn"
|
||||||
|
|
|
@ -5,7 +5,7 @@ workspace = ".."
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
enum-set = { git = "https://github.com/rnewman/enum-set" }
|
enum-set = { git = "https://github.com/rnewman/enum-set" }
|
||||||
error-chain = "0.8.1"
|
error-chain = { git = "https://github.com/rnewman/error-chain", branch = "rnewman/sync" }
|
||||||
|
|
||||||
[dependencies.mentat_core]
|
[dependencies.mentat_core]
|
||||||
path = "../core"
|
path = "../core"
|
||||||
|
@ -18,5 +18,5 @@ path = "../query"
|
||||||
path = "../query-parser"
|
path = "../query-parser"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
itertools = "0.5"
|
itertools = "0.7"
|
||||||
maplit = "0.1"
|
maplit = "0.1"
|
||||||
|
|
|
@ -35,10 +35,8 @@ use mentat_query_algebrizer::{
|
||||||
EmptyBecause,
|
EmptyBecause,
|
||||||
Error,
|
Error,
|
||||||
ErrorKind,
|
ErrorKind,
|
||||||
QueryInputs,
|
|
||||||
ValueTypeSet,
|
ValueTypeSet,
|
||||||
algebrize,
|
algebrize,
|
||||||
algebrize_with_inputs,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// These are helpers that tests use to build Schema instances.
|
// These are helpers that tests use to build Schema instances.
|
||||||
|
|
|
@ -5,7 +5,7 @@ workspace = ".."
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
combine = "2.3.2"
|
combine = "2.3.2"
|
||||||
error-chain = "0.8.1"
|
error-chain = { git = "https://github.com/rnewman/error-chain", branch = "rnewman/sync" }
|
||||||
maplit = "0.1"
|
maplit = "0.1"
|
||||||
matches = "0.1"
|
matches = "0.1"
|
||||||
|
|
||||||
|
|
|
@ -830,19 +830,19 @@ mod test {
|
||||||
let mut par = Query::natural_number();
|
let mut par = Query::natural_number();
|
||||||
let x = par.parse(input.atom_stream()).err().expect("an error").errors;
|
let x = par.parse(input.atom_stream()).err().expect("an error").errors;
|
||||||
let result = format!("{:?}", x);
|
let result = format!("{:?}", x);
|
||||||
assert_eq!(result, "[Other(Error(InvalidLimit(Text(\"foo\")), State { next_error: None, backtrace: None })), Expected(Borrowed(\"natural_number\"))]");
|
assert_eq!(result, "[Other(Error(InvalidLimit(Text(\"foo\")), State { next_error: None, backtrace: None }))]");
|
||||||
|
|
||||||
let input = neg.with_spans();
|
let input = neg.with_spans();
|
||||||
let mut par = Query::natural_number();
|
let mut par = Query::natural_number();
|
||||||
let x = par.parse(input.atom_stream()).err().expect("an error").errors;
|
let x = par.parse(input.atom_stream()).err().expect("an error").errors;
|
||||||
let result = format!("{:?}", x);
|
let result = format!("{:?}", x);
|
||||||
assert_eq!(result, "[Other(Error(InvalidLimit(Integer(-10)), State { next_error: None, backtrace: None })), Expected(Borrowed(\"natural_number\"))]");
|
assert_eq!(result, "[Other(Error(InvalidLimit(Integer(-10)), State { next_error: None, backtrace: None }))]");
|
||||||
|
|
||||||
let input = zero.with_spans();
|
let input = zero.with_spans();
|
||||||
let mut par = Query::natural_number();
|
let mut par = Query::natural_number();
|
||||||
let x = par.parse(input.atom_stream()).err().expect("an error").errors;
|
let x = par.parse(input.atom_stream()).err().expect("an error").errors;
|
||||||
let result = format!("{:?}", x);
|
let result = format!("{:?}", x);
|
||||||
assert_eq!(result, "[Other(Error(InvalidLimit(Integer(0)), State { next_error: None, backtrace: None })), Expected(Borrowed(\"natural_number\"))]");
|
assert_eq!(result, "[Other(Error(InvalidLimit(Integer(0)), State { next_error: None, backtrace: None }))]");
|
||||||
|
|
||||||
let input = pos.with_spans();
|
let input = pos.with_spans();
|
||||||
let mut par = Query::natural_number();
|
let mut par = Query::natural_number();
|
||||||
|
|
|
@ -4,10 +4,10 @@ version = "0.0.1"
|
||||||
workspace = ".."
|
workspace = ".."
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
error-chain = "0.8.1"
|
error-chain = { git = "https://github.com/rnewman/error-chain", branch = "rnewman/sync" }
|
||||||
|
|
||||||
[dependencies.rusqlite]
|
[dependencies.rusqlite]
|
||||||
version = "0.11"
|
version = "0.12"
|
||||||
# System sqlite might be very old.
|
# System sqlite might be very old.
|
||||||
features = ["bundled", "limits"]
|
features = ["bundled", "limits"]
|
||||||
|
|
||||||
|
|
|
@ -112,19 +112,19 @@ impl ToConstraint for ColumnConstraint {
|
||||||
let tag_column = qa.for_type_tag().to_column();
|
let tag_column = qa.for_type_tag().to_column();
|
||||||
let value_column = qa.to_column();
|
let value_column = qa.to_column();
|
||||||
|
|
||||||
/// A bare long in a query might match a ref, an instant, a long (obviously), or a
|
// A bare long in a query might match a ref, an instant, a long (obviously), or a
|
||||||
/// double. If it's negative, it can't match a ref, but that's OK -- it won't!
|
// double. If it's negative, it can't match a ref, but that's OK -- it won't!
|
||||||
///
|
//
|
||||||
/// However, '1' and '0' are used to represent booleans, and some integers are also
|
// However, '1' and '0' are used to represent booleans, and some integers are also
|
||||||
/// used to represent FTS values. We don't want to accidentally match those.
|
// used to represent FTS values. We don't want to accidentally match those.
|
||||||
///
|
//
|
||||||
/// We ask `SQLValueType` whether this value is in range for how booleans are
|
// We ask `SQLValueType` whether this value is in range for how booleans are
|
||||||
/// represented in the database.
|
// represented in the database.
|
||||||
///
|
//
|
||||||
/// We only hit this code path when the attribute is unknown, so we're querying
|
// We only hit this code path when the attribute is unknown, so we're querying
|
||||||
/// `all_datoms`. That means we don't see FTS IDs at all -- they're transparently
|
// `all_datoms`. That means we don't see FTS IDs at all -- they're transparently
|
||||||
/// replaced by their strings. If that changes, then you should also exclude the
|
// replaced by their strings. If that changes, then you should also exclude the
|
||||||
/// string type code (10) here.
|
// string type code (10) here.
|
||||||
let must_exclude_boolean = ValueType::Boolean.accommodates_integer(value);
|
let must_exclude_boolean = ValueType::Boolean.accommodates_integer(value);
|
||||||
if must_exclude_boolean {
|
if must_exclude_boolean {
|
||||||
Constraint::And {
|
Constraint::And {
|
||||||
|
|
|
@ -46,7 +46,7 @@ use edn::{
|
||||||
DateTime,
|
DateTime,
|
||||||
OrderedFloat,
|
OrderedFloat,
|
||||||
Uuid,
|
Uuid,
|
||||||
UTC,
|
Utc,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub use edn::{
|
pub use edn::{
|
||||||
|
@ -193,7 +193,7 @@ pub enum NonIntegerConstant {
|
||||||
BigInteger(BigInt),
|
BigInteger(BigInt),
|
||||||
Float(OrderedFloat<f64>),
|
Float(OrderedFloat<f64>),
|
||||||
Text(Rc<String>),
|
Text(Rc<String>),
|
||||||
Instant(DateTime<UTC>),
|
Instant(DateTime<Utc>),
|
||||||
Uuid(Uuid),
|
Uuid(Uuid),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,11 +4,11 @@ version = "0.0.1"
|
||||||
workspace = ".."
|
workspace = ".."
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
error-chain = "0.8.1"
|
error-chain = { git = "https://github.com/rnewman/error-chain", branch = "rnewman/sync" }
|
||||||
ordered-float = "0.4.0"
|
ordered-float = "0.5"
|
||||||
|
|
||||||
[dependencies.rusqlite]
|
[dependencies.rusqlite]
|
||||||
version = "0.11"
|
version = "0.12"
|
||||||
# System sqlite might be very old.
|
# System sqlite might be very old.
|
||||||
features = ["bundled", "limits"]
|
features = ["bundled", "limits"]
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ use chrono::FixedOffset;
|
||||||
use mentat_core::{
|
use mentat_core::{
|
||||||
TypedValue,
|
TypedValue,
|
||||||
ValueType,
|
ValueType,
|
||||||
UTC,
|
Utc,
|
||||||
Uuid,
|
Uuid,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -220,7 +220,7 @@ fn test_unbound_inputs() {
|
||||||
fn test_instants_and_uuids() {
|
fn test_instants_and_uuids() {
|
||||||
// We assume, perhaps foolishly, that the clocks on test machines won't lose more than an
|
// We assume, perhaps foolishly, that the clocks on test machines won't lose more than an
|
||||||
// hour while this test is running.
|
// hour while this test is running.
|
||||||
let start = UTC::now() + FixedOffset::west(60 * 60);
|
let start = Utc::now() + FixedOffset::west(60 * 60);
|
||||||
|
|
||||||
let mut c = new_connection("").expect("Couldn't open conn.");
|
let mut c = new_connection("").expect("Couldn't open conn.");
|
||||||
let mut conn = Conn::connect(&mut c).expect("Couldn't open DB.");
|
let mut conn = Conn::connect(&mut c).expect("Couldn't open DB.");
|
||||||
|
|
|
@ -5,7 +5,7 @@ workspace = ".."
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
combine = "2.3.2"
|
combine = "2.3.2"
|
||||||
error-chain = "0.8.1"
|
error-chain = { git = "https://github.com/rnewman/error-chain", branch = "rnewman/sync" }
|
||||||
|
|
||||||
[dependencies.edn]
|
[dependencies.edn]
|
||||||
path = "../edn"
|
path = "../edn"
|
||||||
|
|
Loading…
Reference in a new issue