Pre: Move query-algebrizer/error.rs into query-algebrizer-traits

This commit is contained in:
Grisha Kruglov 2018-08-08 11:56:27 -07:00 committed by Grisha Kruglov
parent 9fd198f96a
commit ccdd17551a
26 changed files with 85 additions and 31 deletions

View file

@ -61,6 +61,9 @@ path = "db-traits"
[dependencies.mentat_query_algebrizer] [dependencies.mentat_query_algebrizer]
path = "query-algebrizer" path = "query-algebrizer"
[dependencies.query_algebrizer_traits]
path = "query-algebrizer-traits"
[dependencies.mentat_query_projector] [dependencies.mentat_query_projector]
path = "query-projector" path = "query-projector"

View file

@ -0,0 +1,18 @@
[package]
name = "query_algebrizer_traits"
version = "0.0.1"
workspace = ".."
[lib]
name = "query_algebrizer_traits"
path = "lib.rs"
[dependencies]
failure = "0.1.1"
failure_derive = "0.1.1"
[dependencies.edn]
path = "../edn"
[dependencies.core_traits]
path = "../core-traits"

View file

@ -0,0 +1,18 @@
// 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 core_traits;
extern crate edn;
pub mod errors;

View file

@ -5,7 +5,6 @@ workspace = ".."
[dependencies] [dependencies]
failure = "0.1.1" failure = "0.1.1"
failure_derive = "0.1.1"
[dependencies.edn] [dependencies.edn]
path = "../edn" path = "../edn"
@ -16,5 +15,8 @@ path = "../core"
[dependencies.core_traits] [dependencies.core_traits]
path = "../core-traits" path = "../core-traits"
[dependencies.query_algebrizer_traits]
path = "../query-algebrizer-traits"
[dev-dependencies] [dev-dependencies]
itertools = "0.7" itertools = "0.7"

View file

@ -30,7 +30,7 @@ use clauses::{
ConjoiningClauses, ConjoiningClauses,
}; };
use errors::{ use query_algebrizer_traits::errors::{
AlgebrizerError, AlgebrizerError,
Result, Result,
}; };

View file

@ -32,7 +32,7 @@ use clauses::{
ConjoiningClauses, ConjoiningClauses,
}; };
use errors::{ use query_algebrizer_traits::errors::{
AlgebrizerError, AlgebrizerError,
BindingError, BindingError,
Result, Result,

View file

@ -33,7 +33,7 @@ use clauses::{
use clauses::convert::ValueConversion; use clauses::convert::ValueConversion;
use errors::{ use query_algebrizer_traits::errors::{
AlgebrizerError, AlgebrizerError,
BindingError, BindingError,
Result, Result,

View file

@ -19,7 +19,7 @@ use edn::query::{
Variable, Variable,
}; };
use errors::{ use query_algebrizer_traits::errors::{
AlgebrizerError, AlgebrizerError,
Result, Result,
}; };

View file

@ -52,7 +52,7 @@ use edn::query::{
PatternNonValuePlace, PatternNonValuePlace,
}; };
use errors::{ use query_algebrizer_traits::errors::{
AlgebrizerError, AlgebrizerError,
Result, Result,
}; };

View file

@ -16,7 +16,7 @@ use edn::query::{
use clauses::ConjoiningClauses; use clauses::ConjoiningClauses;
use errors::{ use query_algebrizer_traits::errors::{
AlgebrizerError, AlgebrizerError,
Result, Result,
}; };
@ -113,7 +113,7 @@ mod testing {
associate_ident, associate_ident,
}; };
use errors::{ use query_algebrizer_traits::errors::{
AlgebrizerError, AlgebrizerError,
}; };

View file

@ -34,7 +34,7 @@ use clauses::{
PushComputed, PushComputed,
}; };
use errors::{ use query_algebrizer_traits::errors::{
Result, Result,
}; };

View file

@ -28,7 +28,7 @@ use clauses::ConjoiningClauses;
use clauses::convert::ValueTypes; use clauses::convert::ValueTypes;
use errors::{ use query_algebrizer_traits::errors::{
AlgebrizerError, AlgebrizerError,
Result, Result,
}; };

View file

@ -26,7 +26,7 @@ use edn::query::{
use clauses::ConjoiningClauses; use clauses::ConjoiningClauses;
use errors::{ use query_algebrizer_traits::errors::{
AlgebrizerError, AlgebrizerError,
Result, Result,
}; };

View file

@ -24,7 +24,7 @@ use clauses::{
ConjoiningClauses, ConjoiningClauses,
}; };
use errors::{ use query_algebrizer_traits::errors::{
AlgebrizerError, AlgebrizerError,
BindingError, BindingError,
Result, Result,

View file

@ -16,7 +16,7 @@ use clauses::{
ConjoiningClauses, ConjoiningClauses,
}; };
use errors::{ use query_algebrizer_traits::errors::{
AlgebrizerError, AlgebrizerError,
Result, Result,
}; };

View file

@ -10,18 +10,16 @@
extern crate failure; extern crate failure;
#[macro_use] extern crate failure_derive;
extern crate edn; extern crate edn;
extern crate mentat_core; extern crate mentat_core;
extern crate core_traits; extern crate core_traits;
#[macro_use]
extern crate query_algebrizer_traits;
use std::collections::BTreeSet; use std::collections::BTreeSet;
use std::ops::Sub; use std::ops::Sub;
use std::rc::Rc; use std::rc::Rc;
#[macro_use]
mod errors;
mod types; mod types;
mod validate; mod validate;
mod clauses; mod clauses;
@ -51,9 +49,8 @@ use edn::query::{
WhereClause, WhereClause,
}; };
pub use errors::{ use query_algebrizer_traits::errors::{
AlgebrizerError, AlgebrizerError,
BindingError,
Result, Result,
}; };

View file

@ -18,7 +18,7 @@ use edn::query::{
UnifyVars, UnifyVars,
}; };
use errors::{ use query_algebrizer_traits::errors::{
AlgebrizerError, AlgebrizerError,
Result, Result,
}; };

View file

@ -12,6 +12,7 @@ extern crate edn;
extern crate mentat_core; extern crate mentat_core;
extern crate core_traits; extern crate core_traits;
extern crate mentat_query_algebrizer; extern crate mentat_query_algebrizer;
extern crate query_algebrizer_traits;
mod utils; mod utils;

View file

@ -12,6 +12,7 @@ extern crate edn;
extern crate mentat_core; extern crate mentat_core;
extern crate core_traits; extern crate core_traits;
extern crate mentat_query_algebrizer; extern crate mentat_query_algebrizer;
extern crate query_algebrizer_traits;
mod utils; mod utils;
@ -33,9 +34,12 @@ use edn::query::{
Variable, Variable,
}; };
use mentat_query_algebrizer::{ use query_algebrizer_traits::errors::{
AlgebrizerError, AlgebrizerError,
BindingError, BindingError,
};
use mentat_query_algebrizer::{
ComputedTable, ComputedTable,
Known, Known,
QueryInputs, QueryInputs,

View file

@ -12,6 +12,7 @@ extern crate edn;
extern crate mentat_core; extern crate mentat_core;
extern crate core_traits; extern crate core_traits;
extern crate mentat_query_algebrizer; extern crate mentat_query_algebrizer;
extern crate query_algebrizer_traits;
mod utils; mod utils;
@ -34,8 +35,11 @@ use edn::query::{
Variable, Variable,
}; };
use mentat_query_algebrizer::{ use query_algebrizer_traits::errors::{
AlgebrizerError, AlgebrizerError,
};
use mentat_query_algebrizer::{
EmptyBecause, EmptyBecause,
Known, Known,
QueryInputs, QueryInputs,

View file

@ -12,6 +12,7 @@ extern crate edn;
extern crate core_traits; extern crate core_traits;
extern crate mentat_core; extern crate mentat_core;
extern crate mentat_query_algebrizer; extern crate mentat_query_algebrizer;
extern crate query_algebrizer_traits;
mod utils; mod utils;

View file

@ -27,8 +27,11 @@ use edn::query::{
Keyword, Keyword,
}; };
use mentat_query_algebrizer::{ use query_algebrizer_traits::errors::{
AlgebrizerError, AlgebrizerError,
};
use mentat_query_algebrizer::{
ConjoiningClauses, ConjoiningClauses,
Known, Known,
QueryInputs, QueryInputs,

View file

@ -27,7 +27,9 @@ use mentat_core::{
}; };
use db_traits::errors::DbError; use db_traits::errors::DbError;
use mentat_query_algebrizer; use query_algebrizer_traits::errors::{
AlgebrizerError,
};
use mentat_query_projector; use mentat_query_projector;
use query_pull_traits::errors::{ use query_pull_traits::errors::{
PullError, PullError,
@ -102,7 +104,7 @@ pub enum MentatError {
DbError(#[cause] DbError), DbError(#[cause] DbError),
#[fail(display = "{}", _0)] #[fail(display = "{}", _0)]
AlgebrizerError(#[cause] mentat_query_algebrizer::AlgebrizerError), AlgebrizerError(#[cause] AlgebrizerError),
#[fail(display = "{}", _0)] #[fail(display = "{}", _0)]
ProjectorError(#[cause] mentat_query_projector::ProjectorError), ProjectorError(#[cause] mentat_query_projector::ProjectorError),
@ -142,8 +144,8 @@ impl From<DbError> for MentatError {
} }
} }
impl From<mentat_query_algebrizer::AlgebrizerError> for MentatError { impl From<AlgebrizerError> for MentatError {
fn from(error: mentat_query_algebrizer::AlgebrizerError) -> MentatError { fn from(error: AlgebrizerError) -> MentatError {
MentatError::AlgebrizerError(error) MentatError::AlgebrizerError(error)
} }
} }

View file

@ -27,6 +27,7 @@ extern crate core_traits;
extern crate mentat_db; extern crate mentat_db;
extern crate db_traits; extern crate db_traits;
extern crate mentat_query_algebrizer; extern crate mentat_query_algebrizer;
extern crate query_algebrizer_traits;
extern crate mentat_query_projector; extern crate mentat_query_projector;
extern crate mentat_query_pull; extern crate mentat_query_pull;
extern crate query_pull_traits; extern crate query_pull_traits;
@ -139,7 +140,7 @@ pub use edn::{
ToMicros, ToMicros,
ToMillis, ToMillis,
}; };
pub use mentat_query_algebrizer::AlgebrizerError; pub use query_algebrizer_traits::errors::AlgebrizerError;
pub use mentat_query_projector::{ pub use mentat_query_projector::{
BindingTuple, BindingTuple,
ProjectorError, ProjectorError,

View file

@ -18,7 +18,7 @@ extern crate core_traits;
extern crate mentat_db; extern crate mentat_db;
// TODO: when we switch to `failure`, make this more humane. // TODO: when we switch to `failure`, make this more humane.
extern crate mentat_query_algebrizer; // For errors. extern crate query_algebrizer_traits; // For errors;
extern crate mentat_query_projector; // For errors. extern crate mentat_query_projector; // For errors.
extern crate mentat_query_translator; // For errors. extern crate mentat_query_translator; // For errors.
@ -416,7 +416,7 @@ fn test_fulltext() {
]"#; ]"#;
let r = conn.q_once(&mut c, query, None); let r = conn.q_once(&mut c, query, None);
match r.expect_err("expected query to fail") { match r.expect_err("expected query to fail") {
MentatError::AlgebrizerError(mentat_query_algebrizer::AlgebrizerError::InvalidArgument(PlainSymbol(s), ty, i)) => { MentatError::AlgebrizerError(query_algebrizer_traits::errors::AlgebrizerError::InvalidArgument(PlainSymbol(s), ty, i)) => {
assert_eq!(s, "fulltext"); assert_eq!(s, "fulltext");
assert_eq!(ty, "string"); assert_eq!(ty, "string");
assert_eq!(i, 2); assert_eq!(i, 2);
@ -431,7 +431,7 @@ fn test_fulltext() {
[(fulltext $ :foo/fts ?a) [[?x ?val]]]]"#; [(fulltext $ :foo/fts ?a) [[?x ?val]]]]"#;
let r = conn.q_once(&mut c, query, None); let r = conn.q_once(&mut c, query, None);
match r.expect_err("expected query to fail") { match r.expect_err("expected query to fail") {
MentatError::AlgebrizerError(mentat_query_algebrizer::AlgebrizerError::InvalidArgument(PlainSymbol(s), ty, i)) => { MentatError::AlgebrizerError(query_algebrizer_traits::errors::AlgebrizerError::InvalidArgument(PlainSymbol(s), ty, i)) => {
assert_eq!(s, "fulltext"); assert_eq!(s, "fulltext");
assert_eq!(ty, "string"); assert_eq!(ty, "string");
assert_eq!(i, 2); assert_eq!(i, 2);