fix: build sqlite and mysql without nightly

This commit is contained in:
Dmitriy Pleshevskiy 2021-10-22 01:16:41 +03:00
parent d300edd14b
commit 132f86ba2a
6 changed files with 12 additions and 2 deletions

2
Cargo.lock generated
View File

@ -1089,7 +1089,7 @@ checksum = "692fcb63b64b1758029e0a96ee63e049ce8c5948587f2f7208df04625e5f6b56"
[[package]]
name = "ood_persistence"
version = "0.3.0"
version = "0.3.1"
dependencies = [
"async-trait",
"bb8",

View File

@ -1,6 +1,6 @@
[package]
name = "ood_persistence"
version = "0.3.0"
version = "0.3.1"
edition = "2018"
authors = ["Dmitriy Pleshevskiy <dmitriy@ideascup.me>"]
repository = "https://github.com/pleshevskiy/ood_persistence"

View File

@ -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.

View File

@ -8,6 +8,7 @@ pub use r2d2_mysql::MysqlConnectionManager as Manager;
/// Inner connection of r2d2 implementation.
pub type InnerConn = PooledConnection<Manager>;
/// 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)

View File

@ -9,6 +9,7 @@ pub use r2d2_postgres::PostgresConnectionManager as Manager;
/// Inner connection of r2d2 implementation.
pub type InnerConn<M> = PooledConnection<M>;
/// Inner transaction of postgres.
#[cfg(feature = "nightly")]
pub type InnerTrx<'t> = postgres::Transaction<'t>;
/// Alias for r2d2 postgres no tls manager.

View File

@ -8,6 +8,7 @@ pub use r2d2_sqlite::SqliteConnectionManager as Manager;
/// Inner connection of r2d2 implementation.
pub type InnerConn = PooledConnection<Manager>;
/// 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)