Fix clippy warning
This commit is contained in:
parent
df4df87d09
commit
8d0ba28b7e
@ -193,7 +193,7 @@ impl<'a> ConnectionTrait<'a> for DatabaseConnection {
|
||||
DatabaseConnection::MockDatabaseConnection(conn) => {
|
||||
let transaction = DatabaseTransaction::new_mock(Arc::clone(conn))
|
||||
.await
|
||||
.map_err(|e| TransactionError::Connection(e))?;
|
||||
.map_err(TransactionError::Connection)?;
|
||||
transaction.run(_callback).await
|
||||
}
|
||||
DatabaseConnection::Disconnected => panic!("Disconnected"),
|
||||
@ -202,10 +202,7 @@ impl<'a> ConnectionTrait<'a> for DatabaseConnection {
|
||||
|
||||
#[cfg(feature = "mock")]
|
||||
fn is_mock_connection(&self) -> bool {
|
||||
match self {
|
||||
DatabaseConnection::MockDatabaseConnection(_) => true,
|
||||
_ => false,
|
||||
}
|
||||
matches!(self, DatabaseConnection::MockDatabaseConnection(_))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -110,15 +110,15 @@ impl DatabaseTransaction {
|
||||
{
|
||||
let res = callback(&self)
|
||||
.await
|
||||
.map_err(|e| TransactionError::Transaction(e));
|
||||
.map_err(TransactionError::Transaction);
|
||||
if res.is_ok() {
|
||||
self.commit()
|
||||
.await
|
||||
.map_err(|e| TransactionError::Connection(e))?;
|
||||
.map_err(TransactionError::Connection)?;
|
||||
} else {
|
||||
self.rollback()
|
||||
.await
|
||||
.map_err(|e| TransactionError::Connection(e))?;
|
||||
.map_err(TransactionError::Connection)?;
|
||||
}
|
||||
res
|
||||
}
|
||||
@ -341,7 +341,7 @@ impl<'a> ConnectionTrait<'a> for DatabaseTransaction {
|
||||
let transaction = self
|
||||
.begin()
|
||||
.await
|
||||
.map_err(|e| TransactionError::Connection(e))?;
|
||||
.map_err(TransactionError::Connection)?;
|
||||
transaction.run(_callback).await
|
||||
}
|
||||
}
|
||||
|
@ -114,7 +114,7 @@ impl MockDatabaseConnection {
|
||||
statement: &Statement,
|
||||
) -> Pin<Box<dyn Stream<Item = Result<QueryResult, DbErr>>>> {
|
||||
match self.query_all(statement.clone()) {
|
||||
Ok(v) => Box::pin(futures::stream::iter(v.into_iter().map(|r| Ok(r)))),
|
||||
Ok(v) => Box::pin(futures::stream::iter(v.into_iter().map(Ok))),
|
||||
Err(e) => Box::pin(futures::stream::iter(Some(Err(e)).into_iter())),
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user