Pre: Move db/errors.rs into db_traits
This commit is contained in:
parent
d0214fad7d
commit
cebb85a7fe
33 changed files with 100 additions and 42 deletions
|
@ -55,6 +55,9 @@ path = "sql"
|
|||
[dependencies.mentat_db]
|
||||
path = "db"
|
||||
|
||||
[dependencies.db_traits]
|
||||
path = "db-traits"
|
||||
|
||||
[dependencies.mentat_query]
|
||||
path = "query"
|
||||
|
||||
|
|
22
db-traits/Cargo.toml
Normal file
22
db-traits/Cargo.toml
Normal file
|
@ -0,0 +1,22 @@
|
|||
[package]
|
||||
name = "db_traits"
|
||||
version = "0.0.1"
|
||||
workspace = ".."
|
||||
|
||||
[lib]
|
||||
name = "db_traits"
|
||||
path = "lib.rs"
|
||||
|
||||
[dependencies]
|
||||
failure = "0.1.1"
|
||||
failure_derive = "0.1.1"
|
||||
|
||||
[dependencies.edn]
|
||||
path = "../edn"
|
||||
|
||||
[dependencies.core_traits]
|
||||
path = "../core-traits"
|
||||
|
||||
[dependencies.rusqlite]
|
||||
version = "0.13"
|
||||
features = ["limits"]
|
20
db-traits/lib.rs
Normal file
20
db-traits/lib.rs
Normal file
|
@ -0,0 +1,20 @@
|
|||
// Copyright 2018 Mozilla
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
||||
// this file except in compliance with the License. You may obtain a copy of the
|
||||
// License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
// Unless required by applicable law or agreed to in writing, software distributed
|
||||
// under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
||||
// CONDITIONS OF ANY KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations under the License.
|
||||
|
||||
|
||||
extern crate failure;
|
||||
#[macro_use]
|
||||
extern crate failure_derive;
|
||||
extern crate rusqlite;
|
||||
|
||||
extern crate edn;
|
||||
extern crate core_traits;
|
||||
|
||||
pub mod errors;
|
|
@ -10,7 +10,6 @@ syncable = ["serde", "serde_json", "serde_derive"]
|
|||
|
||||
[dependencies]
|
||||
failure = "0.1.1"
|
||||
failure_derive = "0.1.1"
|
||||
indexmap = "1"
|
||||
itertools = "0.7"
|
||||
lazy_static = "0.2"
|
||||
|
@ -35,6 +34,9 @@ path = "../core"
|
|||
[dependencies.core_traits]
|
||||
path = "../core-traits"
|
||||
|
||||
[dependencies.db_traits]
|
||||
path = "../db-traits"
|
||||
|
||||
[dependencies.mentat_sql]
|
||||
path = "../sql"
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
#![allow(dead_code)]
|
||||
|
||||
use edn;
|
||||
use errors::{
|
||||
use db_traits::errors::{
|
||||
DbErrorKind,
|
||||
Result,
|
||||
};
|
||||
|
|
|
@ -110,7 +110,7 @@ use db::{
|
|||
TypedSQLValue,
|
||||
};
|
||||
|
||||
use errors::{
|
||||
use db_traits::errors::{
|
||||
DbError,
|
||||
DbErrorKind,
|
||||
Result,
|
||||
|
|
|
@ -59,10 +59,11 @@ use mentat_core::{
|
|||
ValueRc,
|
||||
};
|
||||
|
||||
use errors::{
|
||||
use db_traits::errors::{
|
||||
DbErrorKind,
|
||||
Result,
|
||||
};
|
||||
|
||||
use metadata;
|
||||
use schema::{
|
||||
SchemaBuilding,
|
||||
|
@ -1237,7 +1238,7 @@ mod tests {
|
|||
use std::collections::{
|
||||
BTreeMap,
|
||||
};
|
||||
use errors;
|
||||
use db_traits::errors as errors;
|
||||
use internal_types::{
|
||||
Term,
|
||||
};
|
||||
|
|
|
@ -65,7 +65,7 @@ use db::*;
|
|||
use db::{read_attribute_map,read_ident_map};
|
||||
use edn;
|
||||
use entids;
|
||||
use errors::Result;
|
||||
use db_traits::errors::Result;
|
||||
|
||||
use core_traits::{
|
||||
Entid,
|
||||
|
|
|
@ -41,8 +41,8 @@ use edn::entities::{
|
|||
TxFunction,
|
||||
};
|
||||
|
||||
use errors;
|
||||
use errors::{
|
||||
use db_traits::errors as errors;
|
||||
use db_traits::errors::{
|
||||
DbErrorKind,
|
||||
Result,
|
||||
};
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
// specific language governing permissions and limitations under the License.
|
||||
|
||||
extern crate failure;
|
||||
#[macro_use] extern crate failure_derive;
|
||||
extern crate indexmap;
|
||||
extern crate itertools;
|
||||
#[macro_use] extern crate lazy_static;
|
||||
|
@ -25,6 +24,7 @@ extern crate time;
|
|||
|
||||
#[macro_use] extern crate edn;
|
||||
#[macro_use] extern crate mentat_core;
|
||||
#[macro_use] extern crate db_traits;
|
||||
extern crate core_traits;
|
||||
extern crate mentat_sql;
|
||||
|
||||
|
@ -32,13 +32,10 @@ use std::iter::repeat;
|
|||
|
||||
use itertools::Itertools;
|
||||
|
||||
pub use errors::{
|
||||
DbError,
|
||||
use db_traits::errors::{
|
||||
DbErrorKind,
|
||||
Result,
|
||||
SchemaConstraintViolation,
|
||||
};
|
||||
#[macro_use] pub mod errors;
|
||||
|
||||
#[macro_use] pub mod debug;
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ use add_retract_alter_set::{
|
|||
};
|
||||
use edn::symbols;
|
||||
use entids;
|
||||
use errors::{
|
||||
use db_traits::errors::{
|
||||
DbErrorKind,
|
||||
Result,
|
||||
};
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
|
||||
use db::TypedSQLValue;
|
||||
use edn;
|
||||
use errors::{
|
||||
use db_traits::errors::{
|
||||
DbErrorKind,
|
||||
Result,
|
||||
};
|
||||
|
|
|
@ -12,7 +12,7 @@ use std::ops::RangeFrom;
|
|||
|
||||
use rusqlite;
|
||||
|
||||
use errors::{
|
||||
use db_traits::errors::{
|
||||
DbErrorKind,
|
||||
Result,
|
||||
};
|
||||
|
|
|
@ -66,8 +66,8 @@ use edn::{
|
|||
Keyword,
|
||||
};
|
||||
use entids;
|
||||
use errors;
|
||||
use errors::{
|
||||
use db_traits::errors as errors;
|
||||
use db_traits::errors::{
|
||||
DbErrorKind,
|
||||
Result,
|
||||
};
|
||||
|
|
|
@ -19,7 +19,7 @@ use core_traits::{
|
|||
ValueType,
|
||||
};
|
||||
|
||||
use errors::{
|
||||
use db_traits::errors::{
|
||||
CardinalityConflict,
|
||||
};
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ use edn::entities::{
|
|||
OpType,
|
||||
};
|
||||
|
||||
use errors::{
|
||||
use db_traits::errors::{
|
||||
Result,
|
||||
};
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ use edn::entities::{
|
|||
TempId,
|
||||
};
|
||||
|
||||
use errors;
|
||||
use db_traits::errors as errors;
|
||||
|
||||
/// Represents one partition of the entid space.
|
||||
#[derive(Clone, Debug, Eq, Hash, Ord, PartialOrd, PartialEq)]
|
||||
|
|
|
@ -21,7 +21,7 @@ use std::collections::{
|
|||
use indexmap;
|
||||
use petgraph::unionfind;
|
||||
|
||||
use errors::{
|
||||
use db_traits::errors::{
|
||||
DbErrorKind,
|
||||
Result,
|
||||
};
|
||||
|
|
|
@ -30,7 +30,7 @@ use edn::entities::{
|
|||
OpType,
|
||||
};
|
||||
|
||||
use errors::{
|
||||
use db_traits::errors::{
|
||||
Result,
|
||||
};
|
||||
|
||||
|
|
|
@ -21,6 +21,9 @@ path = "../core"
|
|||
[dependencies.mentat_db]
|
||||
path = "../db"
|
||||
|
||||
[dependencies.db_traits]
|
||||
path = "../db-traits"
|
||||
|
||||
[dependencies.mentat_sql]
|
||||
path = "../sql"
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ use rusqlite;
|
|||
use mentat_core::{
|
||||
ValueTypeSet,
|
||||
};
|
||||
use mentat_db;
|
||||
use db_traits::errors::DbError;
|
||||
use mentat_query::{
|
||||
PlainSymbol,
|
||||
};
|
||||
|
@ -71,7 +71,7 @@ pub enum ProjectorError {
|
|||
RusqliteError(String),
|
||||
|
||||
#[fail(display = "{}", _0)]
|
||||
DbError(#[cause] mentat_db::DbError),
|
||||
DbError(#[cause] DbError),
|
||||
|
||||
#[fail(display = "{}", _0)]
|
||||
PullError(#[cause] mentat_query_pull::PullError),
|
||||
|
@ -83,8 +83,8 @@ impl From<rusqlite::Error> for ProjectorError {
|
|||
}
|
||||
}
|
||||
|
||||
impl From<mentat_db::DbError> for ProjectorError {
|
||||
fn from(error: mentat_db::DbError) -> ProjectorError {
|
||||
impl From<DbError> for ProjectorError {
|
||||
fn from(error: DbError) -> ProjectorError {
|
||||
ProjectorError::DbError(error)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@ extern crate indexmap;
|
|||
extern crate rusqlite;
|
||||
|
||||
extern crate mentat_core;
|
||||
extern crate db_traits;
|
||||
extern crate core_traits;
|
||||
extern crate mentat_db; // For value conversion.
|
||||
extern crate mentat_query;
|
||||
|
|
|
@ -20,6 +20,9 @@ path = "../core-traits"
|
|||
[dependencies.mentat_db]
|
||||
path = "../db"
|
||||
|
||||
[dependencies.db_traits]
|
||||
path = "../db-traits"
|
||||
|
||||
[dependencies.mentat_query]
|
||||
path = "../query"
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
use std; // To refer to std::result::Result.
|
||||
|
||||
use mentat_db::{
|
||||
use db_traits::errors::{
|
||||
DbError,
|
||||
};
|
||||
|
||||
|
|
|
@ -67,6 +67,7 @@ extern crate rusqlite;
|
|||
extern crate mentat_core;
|
||||
extern crate core_traits;
|
||||
extern crate mentat_db;
|
||||
extern crate db_traits;
|
||||
extern crate mentat_query;
|
||||
extern crate mentat_query_algebrizer;
|
||||
extern crate mentat_query_sql;
|
||||
|
|
|
@ -562,7 +562,7 @@ impl<'a, 'o> TransactWatcher for InProgressTransactWatcher<'a, 'o> {
|
|||
self.observer_watcher.datom(op.clone(), e.clone(), a.clone(), v);
|
||||
}
|
||||
|
||||
fn done(&mut self, t: &Entid, schema: &Schema) -> ::mentat_db::errors::Result<()> {
|
||||
fn done(&mut self, t: &Entid, schema: &Schema) -> ::db_traits::errors::Result<()> {
|
||||
self.cache_watcher.done(t, schema)?;
|
||||
self.observer_watcher.done(t, schema)?;
|
||||
self.tx_id = Some(t.clone());
|
||||
|
@ -895,7 +895,7 @@ mod tests {
|
|||
|
||||
match conn.transact(&mut sqlite, t.as_str()) {
|
||||
Err(MentatError::DbError(e)) => {
|
||||
assert_eq!(e.kind(), ::mentat_db::DbErrorKind::UnrecognizedEntid(next + 1));
|
||||
assert_eq!(e.kind(), ::db_traits::errors::DbErrorKind::UnrecognizedEntid(next + 1));
|
||||
},
|
||||
x => panic!("expected db error, got {:?}", x),
|
||||
}
|
||||
|
@ -923,7 +923,7 @@ mod tests {
|
|||
match conn.transact(&mut sqlite, t.as_str()) {
|
||||
Err(MentatError::DbError(e)) => {
|
||||
// All this, despite this being the ID we were about to allocate!
|
||||
assert_eq!(e.kind(), ::mentat_db::DbErrorKind::UnrecognizedEntid(next));
|
||||
assert_eq!(e.kind(), ::db_traits::errors::DbErrorKind::UnrecognizedEntid(next));
|
||||
},
|
||||
x => panic!("expected db error, got {:?}", x),
|
||||
}
|
||||
|
@ -1107,7 +1107,7 @@ mod tests {
|
|||
match report.expect_err("expected transact error") {
|
||||
MentatError::DbError(e) => {
|
||||
match e.kind() {
|
||||
::mentat_db::DbErrorKind::SchemaConstraintViolation(_) => {},
|
||||
::db_traits::errors::DbErrorKind::SchemaConstraintViolation(_) => {},
|
||||
_ => panic!("expected SchemaConstraintViolation"),
|
||||
}
|
||||
},
|
||||
|
|
|
@ -282,6 +282,7 @@ impl<'a, 'c> EntityBuilder<InProgressBuilder<'a, 'c>> {
|
|||
#[cfg(test)]
|
||||
mod testing {
|
||||
extern crate mentat_db;
|
||||
extern crate db_traits;
|
||||
|
||||
use ::{
|
||||
Conn,
|
||||
|
@ -326,7 +327,7 @@ mod testing {
|
|||
// This should fail: unrecognized entid.
|
||||
match in_progress.transact_entities(terms).expect_err("expected transact to fail") {
|
||||
MentatError::DbError(e) => {
|
||||
assert_eq!(e.kind(), mentat_db::DbErrorKind::UnrecognizedEntid(999));
|
||||
assert_eq!(e.kind(), db_traits::errors::DbErrorKind::UnrecognizedEntid(999));
|
||||
},
|
||||
_ => panic!("Should have rejected the entid."),
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ use mentat_core::{
|
|||
Attribute,
|
||||
};
|
||||
|
||||
use mentat_db;
|
||||
use db_traits::errors::DbError;
|
||||
use mentat_query;
|
||||
use mentat_query_algebrizer;
|
||||
use mentat_query_projector;
|
||||
|
@ -98,7 +98,7 @@ pub enum MentatError {
|
|||
EdnParseError(#[cause] edn::ParseError),
|
||||
|
||||
#[fail(display = "{}", _0)]
|
||||
DbError(#[cause] mentat_db::DbError),
|
||||
DbError(#[cause] DbError),
|
||||
|
||||
#[fail(display = "{}", _0)]
|
||||
AlgebrizerError(#[cause] mentat_query_algebrizer::AlgebrizerError),
|
||||
|
@ -135,8 +135,8 @@ impl From<edn::ParseError> for MentatError {
|
|||
}
|
||||
}
|
||||
|
||||
impl From<mentat_db::DbError> for MentatError {
|
||||
fn from(error: mentat_db::DbError) -> MentatError {
|
||||
impl From<DbError> for MentatError {
|
||||
fn from(error: DbError) -> MentatError {
|
||||
MentatError::DbError(error)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@ pub extern crate edn;
|
|||
extern crate mentat_core;
|
||||
extern crate core_traits;
|
||||
extern crate mentat_db;
|
||||
extern crate db_traits;
|
||||
extern crate mentat_query;
|
||||
extern crate mentat_query_algebrizer;
|
||||
extern crate mentat_query_projector;
|
||||
|
@ -138,7 +139,6 @@ pub use edn::{
|
|||
ToMicros,
|
||||
ToMillis,
|
||||
};
|
||||
pub use mentat_db::DbError;
|
||||
pub use mentat_query_algebrizer::AlgebrizerError;
|
||||
pub use mentat_query_projector::{
|
||||
BindingTuple,
|
||||
|
|
|
@ -30,6 +30,9 @@ path = "../core-traits"
|
|||
[dependencies.mentat_db]
|
||||
path = "../db"
|
||||
|
||||
[dependencies.db_traits]
|
||||
path = "../db-traits"
|
||||
|
||||
[dependencies.rusqlite]
|
||||
version = "0.13"
|
||||
features = ["limits"]
|
||||
|
|
|
@ -14,7 +14,7 @@ use uuid;
|
|||
use hyper;
|
||||
use serde_json;
|
||||
|
||||
use mentat_db;
|
||||
use db_traits::errors::DbError;
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! bail {
|
||||
|
@ -46,7 +46,7 @@ pub enum TolstoyError {
|
|||
NotYetImplemented(String),
|
||||
|
||||
#[fail(display = "{}", _0)]
|
||||
DbError(#[cause] mentat_db::DbError),
|
||||
DbError(#[cause] DbError),
|
||||
|
||||
#[fail(display = "{}", _0)]
|
||||
SerializationError(#[cause] serde_json::Error),
|
||||
|
@ -69,8 +69,8 @@ pub enum TolstoyError {
|
|||
UriError(#[cause] hyper::error::UriError),
|
||||
}
|
||||
|
||||
impl From<mentat_db::DbError> for TolstoyError {
|
||||
fn from(error: mentat_db::DbError) -> TolstoyError {
|
||||
impl From<DbError> for TolstoyError {
|
||||
fn from(error: DbError) -> TolstoyError {
|
||||
TolstoyError::DbError(error)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,6 +34,7 @@ extern crate serde_json;
|
|||
#[cfg_attr(test, macro_use)] extern crate mentat_db;
|
||||
|
||||
extern crate mentat_core;
|
||||
extern crate db_traits;
|
||||
extern crate core_traits;
|
||||
extern crate rusqlite;
|
||||
extern crate uuid;
|
||||
|
|
Loading…
Reference in a new issue