From 132f86ba2a5baac0732cf8598192fa39975841e6 Mon Sep 17 00:00:00 2001 From: Dmitriy Pleshevskiy Date: Fri, 22 Oct 2021 01:16:41 +0300 Subject: [PATCH] fix: build sqlite and mysql without nightly --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/bb8_postgres.rs | 1 + src/r2d2_mysql.rs | 4 ++++ src/r2d2_postgres.rs | 1 + src/r2d2_sqlite.rs | 4 ++++ 6 files changed, 12 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 207176b..eddcdaf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1089,7 +1089,7 @@ checksum = "692fcb63b64b1758029e0a96ee63e049ce8c5948587f2f7208df04625e5f6b56" [[package]] name = "ood_persistence" -version = "0.3.0" +version = "0.3.1" dependencies = [ "async-trait", "bb8", diff --git a/Cargo.toml b/Cargo.toml index 64fc0e8..d1300ca 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ood_persistence" -version = "0.3.0" +version = "0.3.1" edition = "2018" authors = ["Dmitriy Pleshevskiy "] repository = "https://github.com/pleshevskiy/ood_persistence" diff --git a/src/bb8_postgres.rs b/src/bb8_postgres.rs index b658276..4ee7ada 100644 --- a/src/bb8_postgres.rs +++ b/src/bb8_postgres.rs @@ -9,6 +9,7 @@ pub use bb8_postgres::PostgresConnectionManager as Manager; /// Inner connection of bb8 implementation. pub type InnerConn<'p, M> = PooledConnection<'p, M>; /// Inner connection of tokio postgres connection. +#[cfg(feature = "nightly")] pub type InnerTrx<'p> = tokio_postgres::Transaction<'p>; /// Alias for bb8 postgres no tls manager. diff --git a/src/r2d2_mysql.rs b/src/r2d2_mysql.rs index 3999fda..1053aca 100644 --- a/src/r2d2_mysql.rs +++ b/src/r2d2_mysql.rs @@ -8,6 +8,7 @@ pub use r2d2_mysql::MysqlConnectionManager as Manager; /// Inner connection of r2d2 implementation. pub type InnerConn = PooledConnection; /// Inner transaction of `mysql`. +#[cfg(feature = "nightly")] pub type InnerTrx<'t> = mysql::Transaction<'t>; /// It creates new persistence of r2d2 mysql implementation. @@ -60,8 +61,10 @@ impl ConnectionClient for Connection { /// # Limits /// /// Mysql doesn't support nested transactions +#[cfg(feature = "nightly")] pub struct Transaction<'me>(InnerTrx<'me>); +#[cfg(feature = "nightly")] impl<'me> ConnectionClient for Transaction<'me> { type InnerConn = InnerTrx<'me>; @@ -79,6 +82,7 @@ impl<'me> ConnectionClient for Transaction<'me> { } } +#[cfg(feature = "nightly")] impl TransactionClient for Transaction<'_> { fn commit(self) -> crate::Result<()> { self.0.commit().map_err(|_| crate::Error::CommitTransaction) diff --git a/src/r2d2_postgres.rs b/src/r2d2_postgres.rs index b3a70be..7ecdb7e 100644 --- a/src/r2d2_postgres.rs +++ b/src/r2d2_postgres.rs @@ -9,6 +9,7 @@ pub use r2d2_postgres::PostgresConnectionManager as Manager; /// Inner connection of r2d2 implementation. pub type InnerConn = PooledConnection; /// Inner transaction of postgres. +#[cfg(feature = "nightly")] pub type InnerTrx<'t> = postgres::Transaction<'t>; /// Alias for r2d2 postgres no tls manager. diff --git a/src/r2d2_sqlite.rs b/src/r2d2_sqlite.rs index 32732cf..bb9bb9b 100644 --- a/src/r2d2_sqlite.rs +++ b/src/r2d2_sqlite.rs @@ -8,6 +8,7 @@ pub use r2d2_sqlite::SqliteConnectionManager as Manager; /// Inner connection of r2d2 implementation. pub type InnerConn = PooledConnection; /// Inner transaction of rusqlite. +#[cfg(feature = "nightly")] pub type InnerTrx<'t> = rusqlite::Transaction<'t>; /// It creates new persistence of r2d2 sqlite implementation. @@ -61,8 +62,10 @@ impl ConnectionClient for Connection { /// /// It doesn't support nested transaction, because the transaction in `rusqlite` /// requires `DerefMut`, which cannot be implemented at the moment. 😣 +#[cfg(feature = "nightly")] pub struct Transaction<'me>(InnerTrx<'me>); +#[cfg(feature = "nightly")] impl<'me> ConnectionClient for Transaction<'me> { type InnerConn = InnerTrx<'me>; @@ -86,6 +89,7 @@ impl<'me> ConnectionClient for Transaction<'me> { } } +#[cfg(feature = "nightly")] impl TransactionClient for Transaction<'_> { fn commit(self) -> crate::Result<()> { self.0.commit().map_err(|_| crate::Error::CommitTransaction)