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]] [[package]]
name = "ood_persistence" name = "ood_persistence"
version = "0.3.0" version = "0.3.1"
dependencies = [ dependencies = [
"async-trait", "async-trait",
"bb8", "bb8",

View file

@ -1,6 +1,6 @@
[package] [package]
name = "ood_persistence" name = "ood_persistence"
version = "0.3.0" version = "0.3.1"
edition = "2018" edition = "2018"
authors = ["Dmitriy Pleshevskiy <dmitriy@ideascup.me>"] authors = ["Dmitriy Pleshevskiy <dmitriy@ideascup.me>"]
repository = "https://github.com/pleshevskiy/ood_persistence" 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. /// Inner connection of bb8 implementation.
pub type InnerConn<'p, M> = PooledConnection<'p, M>; pub type InnerConn<'p, M> = PooledConnection<'p, M>;
/// Inner connection of tokio postgres connection. /// Inner connection of tokio postgres connection.
#[cfg(feature = "nightly")]
pub type InnerTrx<'p> = tokio_postgres::Transaction<'p>; pub type InnerTrx<'p> = tokio_postgres::Transaction<'p>;
/// Alias for bb8 postgres no tls manager. /// 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. /// Inner connection of r2d2 implementation.
pub type InnerConn = PooledConnection<Manager>; pub type InnerConn = PooledConnection<Manager>;
/// Inner transaction of `mysql`. /// Inner transaction of `mysql`.
#[cfg(feature = "nightly")]
pub type InnerTrx<'t> = mysql::Transaction<'t>; pub type InnerTrx<'t> = mysql::Transaction<'t>;
/// It creates new persistence of r2d2 mysql implementation. /// It creates new persistence of r2d2 mysql implementation.
@ -60,8 +61,10 @@ impl ConnectionClient for Connection {
/// # Limits /// # Limits
/// ///
/// Mysql doesn't support nested transactions /// Mysql doesn't support nested transactions
#[cfg(feature = "nightly")]
pub struct Transaction<'me>(InnerTrx<'me>); pub struct Transaction<'me>(InnerTrx<'me>);
#[cfg(feature = "nightly")]
impl<'me> ConnectionClient for Transaction<'me> { impl<'me> ConnectionClient for Transaction<'me> {
type InnerConn = InnerTrx<'me>; type InnerConn = InnerTrx<'me>;
@ -79,6 +82,7 @@ impl<'me> ConnectionClient for Transaction<'me> {
} }
} }
#[cfg(feature = "nightly")]
impl TransactionClient for Transaction<'_> { impl TransactionClient for Transaction<'_> {
fn commit(self) -> crate::Result<()> { fn commit(self) -> crate::Result<()> {
self.0.commit().map_err(|_| crate::Error::CommitTransaction) 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. /// Inner connection of r2d2 implementation.
pub type InnerConn<M> = PooledConnection<M>; pub type InnerConn<M> = PooledConnection<M>;
/// Inner transaction of postgres. /// Inner transaction of postgres.
#[cfg(feature = "nightly")]
pub type InnerTrx<'t> = postgres::Transaction<'t>; pub type InnerTrx<'t> = postgres::Transaction<'t>;
/// Alias for r2d2 postgres no tls manager. /// 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. /// Inner connection of r2d2 implementation.
pub type InnerConn = PooledConnection<Manager>; pub type InnerConn = PooledConnection<Manager>;
/// Inner transaction of rusqlite. /// Inner transaction of rusqlite.
#[cfg(feature = "nightly")]
pub type InnerTrx<'t> = rusqlite::Transaction<'t>; pub type InnerTrx<'t> = rusqlite::Transaction<'t>;
/// It creates new persistence of r2d2 sqlite implementation. /// 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` /// It doesn't support nested transaction, because the transaction in `rusqlite`
/// requires `DerefMut`, which cannot be implemented at the moment. 😣 /// requires `DerefMut`, which cannot be implemented at the moment. 😣
#[cfg(feature = "nightly")]
pub struct Transaction<'me>(InnerTrx<'me>); pub struct Transaction<'me>(InnerTrx<'me>);
#[cfg(feature = "nightly")]
impl<'me> ConnectionClient for Transaction<'me> { impl<'me> ConnectionClient for Transaction<'me> {
type InnerConn = InnerTrx<'me>; type InnerConn = InnerTrx<'me>;
@ -86,6 +89,7 @@ impl<'me> ConnectionClient for Transaction<'me> {
} }
} }
#[cfg(feature = "nightly")]
impl TransactionClient for Transaction<'_> { impl TransactionClient for Transaction<'_> {
fn commit(self) -> crate::Result<()> { fn commit(self) -> crate::Result<()> {
self.0.commit().map_err(|_| crate::Error::CommitTransaction) self.0.commit().map_err(|_| crate::Error::CommitTransaction)