Update to Diesel 0.99

This fixes #49
This commit is contained in:
Magnus Hoff 2017-12-15 16:19:44 +01:00
parent 4b1e1f9222
commit b7a7ae53ab
5 changed files with 348 additions and 247 deletions

555
Cargo.lock generated

File diff suppressed because it is too large Load diff

View file

@ -23,8 +23,8 @@ hyper = "0.11"
lazy_static = "0.2" lazy_static = "0.2"
maplit = "1" maplit = "1"
percent-encoding = "1.0.0" percent-encoding = "1.0.0"
r2d2 = "0.7" r2d2 = "0.8"
r2d2-diesel = "0.16" r2d2-diesel = "0.99"
regex = "0.2" regex = "0.2"
serde = "1.0.0" serde = "1.0.0"
serde_derive = "1.0.0" serde_derive = "1.0.0"
@ -38,17 +38,22 @@ tokio-service = "0.1"
[dependencies.libsqlite3-sys] [dependencies.libsqlite3-sys]
features = ["bundled"] features = ["bundled"]
version = "*" version = "0.8"
[dependencies.diesel] [dependencies.diesel]
default-features = false default-features = false
features = ["sqlite", "chrono"] features = ["sqlite", "chrono"]
version = "0.16" version = "0.99"
[dependencies.diesel_codegen] [dependencies.diesel_migrations]
default-features = false default-features = false
features = ["sqlite"] features = ["sqlite"]
version = "0.16" version = "0.99"
[dependencies.diesel_infer_schema]
default-features = false
features = ["sqlite"]
version = "0.99"
[dependencies.num] [dependencies.num]
default-features = false default-features = false
@ -68,6 +73,11 @@ walkdir = "1"
[build-dependencies.diesel] [build-dependencies.diesel]
default-features = false default-features = false
features = ["sqlite", "chrono"] features = ["sqlite", "chrono"]
version = "0.16.0" version = "0.99"
[build-dependencies.diesel_migrations]
default-features = false
features = ["sqlite"]
version = "0.99"
[workspace] [workspace]

View file

@ -1,4 +1,5 @@
#[macro_use] extern crate quote; #[macro_use] extern crate quote;
extern crate diesel_migrations;
extern crate diesel; extern crate diesel;
extern crate walkdir; extern crate walkdir;
@ -25,7 +26,7 @@ fn main() {
.execute(&connection) .execute(&connection)
.expect("Should be able to enable foreign keys"); .expect("Should be able to enable foreign keys");
diesel::migrations::run_pending_migrations(&connection).unwrap(); diesel_migrations::run_pending_migrations(&connection).unwrap();
let infer_schema_path = Path::new(&out_dir).join("infer_schema.rs"); let infer_schema_path = Path::new(&out_dir).join("infer_schema.rs");
let mut file = File::create(infer_schema_path).expect("Unable to open file for writing"); let mut file = File::create(infer_schema_path).expect("Unable to open file for writing");

View file

@ -1,7 +1,7 @@
use diesel::prelude::*; use diesel::prelude::*;
use diesel::expression::sql_literal::sql; use diesel::expression::sql_literal::sql;
use diesel::types::*; use diesel::types::*;
use r2d2::{Config, CustomizeConnection, Pool}; use r2d2::{CustomizeConnection, Pool};
use r2d2_diesel::{self, ConnectionManager}; use r2d2_diesel::{self, ConnectionManager};
embed_migrations!(); embed_migrations!();
@ -19,12 +19,10 @@ impl CustomizeConnection<SqliteConnection, r2d2_diesel::Error> for SqliteInitial
} }
pub fn create_pool<S: Into<String>>(connection_string: S) -> Result<Pool<ConnectionManager<SqliteConnection>>, Box<::std::error::Error>> { pub fn create_pool<S: Into<String>>(connection_string: S) -> Result<Pool<ConnectionManager<SqliteConnection>>, Box<::std::error::Error>> {
let config = Config::builder()
.connection_customizer(Box::new(SqliteInitializer {}))
.build();
let manager = ConnectionManager::<SqliteConnection>::new(connection_string); let manager = ConnectionManager::<SqliteConnection>::new(connection_string);
let pool = Pool::builder()
let pool = Pool::new(config, manager)?; .connection_customizer(Box::new(SqliteInitializer {}))
.build(manager)?;
embedded_migrations::run(&*pool.get()?)?; embedded_migrations::run(&*pool.get()?)?;

View file

@ -4,7 +4,8 @@
#[macro_use] extern crate bart_derive; #[macro_use] extern crate bart_derive;
#[macro_use] extern crate codegen; #[macro_use] extern crate codegen;
#[macro_use] extern crate diesel_codegen; #[macro_use] extern crate diesel_infer_schema;
#[macro_use] extern crate diesel_migrations;
#[macro_use] extern crate diesel; #[macro_use] extern crate diesel;
#[macro_use] extern crate hyper; #[macro_use] extern crate hyper;
#[macro_use] extern crate lazy_static; #[macro_use] extern crate lazy_static;