Pre: Move sql/errors into sql_traits
This commit is contained in:
parent
cd0bd46232
commit
474d17d3da
10 changed files with 77 additions and 20 deletions
|
@ -79,6 +79,9 @@ path = "query-pull-traits"
|
||||||
[dependencies.mentat_query_sql]
|
[dependencies.mentat_query_sql]
|
||||||
path = "query-sql"
|
path = "query-sql"
|
||||||
|
|
||||||
|
[dependencies.sql_traits]
|
||||||
|
path = "sql-traits"
|
||||||
|
|
||||||
[dependencies.mentat_tolstoy]
|
[dependencies.mentat_tolstoy]
|
||||||
path = "tolstoy"
|
path = "tolstoy"
|
||||||
optional = true
|
optional = true
|
||||||
|
|
|
@ -17,5 +17,8 @@ path = "../core"
|
||||||
[dependencies.mentat_sql]
|
[dependencies.mentat_sql]
|
||||||
path = "../sql"
|
path = "../sql"
|
||||||
|
|
||||||
|
[dependencies.sql_traits]
|
||||||
|
path = "../sql-traits"
|
||||||
|
|
||||||
[dependencies.mentat_query_algebrizer]
|
[dependencies.mentat_query_algebrizer]
|
||||||
path = "../query-algebrizer"
|
path = "../query-algebrizer"
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
|
|
||||||
#[macro_use] extern crate mentat_core;
|
#[macro_use] extern crate mentat_core;
|
||||||
extern crate core_traits;
|
extern crate core_traits;
|
||||||
|
extern crate sql_traits;
|
||||||
extern crate edn;
|
extern crate edn;
|
||||||
extern crate mentat_query_algebrizer;
|
extern crate mentat_query_algebrizer;
|
||||||
extern crate mentat_sql;
|
extern crate mentat_sql;
|
||||||
|
@ -42,11 +43,14 @@ use mentat_query_algebrizer::{
|
||||||
VariableColumn,
|
VariableColumn,
|
||||||
};
|
};
|
||||||
|
|
||||||
use mentat_sql::{
|
use sql_traits::errors::{
|
||||||
BuildQueryResult,
|
BuildQueryResult,
|
||||||
|
SQLError,
|
||||||
|
};
|
||||||
|
|
||||||
|
use mentat_sql::{
|
||||||
QueryBuilder,
|
QueryBuilder,
|
||||||
QueryFragment,
|
QueryFragment,
|
||||||
SQLError,
|
|
||||||
SQLiteQueryBuilder,
|
SQLiteQueryBuilder,
|
||||||
SQLQuery,
|
SQLQuery,
|
||||||
};
|
};
|
||||||
|
|
12
sql-traits/Cargo.toml
Normal file
12
sql-traits/Cargo.toml
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
[package]
|
||||||
|
name = "sql_traits"
|
||||||
|
version = "0.0.1"
|
||||||
|
workspace = ".."
|
||||||
|
|
||||||
|
[lib]
|
||||||
|
name = "sql_traits"
|
||||||
|
path = "lib.rs"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
failure = "0.1.1"
|
||||||
|
failure_derive = "0.1.1"
|
20
sql-traits/errors.rs
Normal file
20
sql-traits/errors.rs
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
// Copyright 2016 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.
|
||||||
|
|
||||||
|
#[derive(Debug, Fail)]
|
||||||
|
pub enum SQLError {
|
||||||
|
#[fail(display = "invalid parameter name: {}", _0)]
|
||||||
|
InvalidParameterName(String),
|
||||||
|
|
||||||
|
#[fail(display = "parameter name could be generated: '{}'", _0)]
|
||||||
|
BindParamCouldBeGenerated(String)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub type BuildQueryResult = Result<(), SQLError>;
|
15
sql-traits/lib.rs
Normal file
15
sql-traits/lib.rs
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
// Copyright 2016 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;
|
||||||
|
|
||||||
|
pub mod errors;
|
|
@ -5,7 +5,6 @@ workspace = ".."
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
failure = "0.1.1"
|
failure = "0.1.1"
|
||||||
failure_derive = "0.1.1"
|
|
||||||
ordered-float = "0.5"
|
ordered-float = "0.5"
|
||||||
|
|
||||||
[dependencies.rusqlite]
|
[dependencies.rusqlite]
|
||||||
|
@ -17,3 +16,6 @@ path = "../core-traits"
|
||||||
|
|
||||||
[dependencies.mentat_core]
|
[dependencies.mentat_core]
|
||||||
path = "../core"
|
path = "../core"
|
||||||
|
|
||||||
|
[dependencies.sql_traits]
|
||||||
|
path = "../sql-traits"
|
||||||
|
|
|
@ -7,13 +7,14 @@
|
||||||
// under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
// 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
|
// CONDITIONS OF ANY KIND, either express or implied. See the License for the
|
||||||
// specific language governing permissions and limitations under the License.
|
// specific language governing permissions and limitations under the License.
|
||||||
|
|
||||||
extern crate failure;
|
extern crate failure;
|
||||||
|
|
||||||
#[macro_use] extern crate failure_derive;
|
|
||||||
extern crate ordered_float;
|
extern crate ordered_float;
|
||||||
extern crate rusqlite;
|
extern crate rusqlite;
|
||||||
|
|
||||||
extern crate core_traits;
|
extern crate core_traits;
|
||||||
|
extern crate sql_traits;
|
||||||
extern crate mentat_core;
|
extern crate mentat_core;
|
||||||
|
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
@ -26,6 +27,11 @@ use core_traits::{
|
||||||
TypedValue,
|
TypedValue,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use sql_traits::errors::{
|
||||||
|
BuildQueryResult,
|
||||||
|
SQLError,
|
||||||
|
};
|
||||||
|
|
||||||
use mentat_core::{
|
use mentat_core::{
|
||||||
ToMicros,
|
ToMicros,
|
||||||
ValueRc,
|
ValueRc,
|
||||||
|
@ -33,17 +39,6 @@ use mentat_core::{
|
||||||
|
|
||||||
pub use rusqlite::types::Value;
|
pub use rusqlite::types::Value;
|
||||||
|
|
||||||
#[derive(Debug, Fail)]
|
|
||||||
pub enum SQLError {
|
|
||||||
#[fail(display = "invalid parameter name: {}", _0)]
|
|
||||||
InvalidParameterName(String),
|
|
||||||
|
|
||||||
#[fail(display = "parameter name could be generated: '{}'", _0)]
|
|
||||||
BindParamCouldBeGenerated(String)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub type BuildQueryResult = Result<(), SQLError>;
|
|
||||||
|
|
||||||
/// We want to accumulate values that will later be substituted into a SQL statement execution.
|
/// We want to accumulate values that will later be substituted into a SQL statement execution.
|
||||||
/// This struct encapsulates the generated string and the _initial_ argument list.
|
/// This struct encapsulates the generated string and the _initial_ argument list.
|
||||||
/// Additional user-supplied argument bindings, with their placeholders accumulated via
|
/// Additional user-supplied argument bindings, with their placeholders accumulated via
|
||||||
|
|
|
@ -36,7 +36,9 @@ use query_projector_traits::errors::{
|
||||||
use query_pull_traits::errors::{
|
use query_pull_traits::errors::{
|
||||||
PullError,
|
PullError,
|
||||||
};
|
};
|
||||||
use mentat_sql;
|
use sql_traits::errors::{
|
||||||
|
SQLError,
|
||||||
|
};
|
||||||
|
|
||||||
#[cfg(feature = "syncable")]
|
#[cfg(feature = "syncable")]
|
||||||
use mentat_tolstoy;
|
use mentat_tolstoy;
|
||||||
|
@ -115,7 +117,7 @@ pub enum MentatError {
|
||||||
PullError(#[cause] PullError),
|
PullError(#[cause] PullError),
|
||||||
|
|
||||||
#[fail(display = "{}", _0)]
|
#[fail(display = "{}", _0)]
|
||||||
SQLError(#[cause] mentat_sql::SQLError),
|
SQLError(#[cause] SQLError),
|
||||||
|
|
||||||
#[cfg(feature = "syncable")]
|
#[cfg(feature = "syncable")]
|
||||||
#[fail(display = "{}", _0)]
|
#[fail(display = "{}", _0)]
|
||||||
|
@ -164,8 +166,8 @@ impl From<PullError> for MentatError {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<mentat_sql::SQLError> for MentatError {
|
impl From<SQLError> for MentatError {
|
||||||
fn from(error: mentat_sql::SQLError) -> MentatError {
|
fn from(error: SQLError) -> MentatError {
|
||||||
MentatError::SQLError(error)
|
MentatError::SQLError(error)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,6 +32,7 @@ extern crate mentat_query_projector;
|
||||||
extern crate query_projector_traits;
|
extern crate query_projector_traits;
|
||||||
extern crate mentat_query_pull;
|
extern crate mentat_query_pull;
|
||||||
extern crate query_pull_traits;
|
extern crate query_pull_traits;
|
||||||
|
extern crate sql_traits;
|
||||||
extern crate mentat_sql;
|
extern crate mentat_sql;
|
||||||
|
|
||||||
#[cfg(feature = "syncable")]
|
#[cfg(feature = "syncable")]
|
||||||
|
@ -148,7 +149,7 @@ pub use mentat_query_projector::{
|
||||||
BindingTuple,
|
BindingTuple,
|
||||||
};
|
};
|
||||||
pub use query_pull_traits::errors::PullError;
|
pub use query_pull_traits::errors::PullError;
|
||||||
pub use mentat_sql::SQLError;
|
pub use sql_traits::errors::SQLError;
|
||||||
|
|
||||||
pub mod conn;
|
pub mod conn;
|
||||||
pub mod entity_builder;
|
pub mod entity_builder;
|
||||||
|
|
Loading…
Reference in a new issue