Remove unused Transaction from Txn
Also note about why StorageTxn isn't implemented
This commit is contained in:
@@ -87,17 +87,16 @@ impl SqliteStorage {
|
|||||||
impl Storage for SqliteStorage {
|
impl Storage for SqliteStorage {
|
||||||
fn txn<'a>(&'a self) -> anyhow::Result<Box<dyn StorageTxn + 'a>> {
|
fn txn<'a>(&'a self) -> anyhow::Result<Box<dyn StorageTxn + 'a>> {
|
||||||
let con = self.new_connection()?;
|
let con = self.new_connection()?;
|
||||||
let t = Txn { con, txn: None };
|
let t = Txn { con };
|
||||||
Ok(Box::new(t))
|
Ok(Box::new(t))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Txn<'t> {
|
struct Txn {
|
||||||
con: Connection,
|
con: Connection,
|
||||||
txn: Option<rusqlite::Transaction<'t>>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'t> Txn<'t> {
|
impl Txn {
|
||||||
fn get_txn(&mut self) -> Result<rusqlite::Transaction, SqliteError> {
|
fn get_txn(&mut self) -> Result<rusqlite::Transaction, SqliteError> {
|
||||||
self.con
|
self.con
|
||||||
.transaction()
|
.transaction()
|
||||||
@@ -105,7 +104,7 @@ impl<'t> Txn<'t> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'t> StorageTxn for Txn<'t> {
|
impl StorageTxn for Txn {
|
||||||
fn get_client(&mut self, client_key: Uuid) -> anyhow::Result<Option<Client>> {
|
fn get_client(&mut self, client_key: Uuid) -> anyhow::Result<Option<Client>> {
|
||||||
let t = self.get_txn()?;
|
let t = self.get_txn()?;
|
||||||
let result: Option<Client> = t
|
let result: Option<Client> = t
|
||||||
@@ -195,11 +194,10 @@ impl<'t> StorageTxn for Txn<'t> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn commit(&mut self) -> anyhow::Result<()> {
|
fn commit(&mut self) -> anyhow::Result<()> {
|
||||||
let t: rusqlite::Transaction = self
|
// FIXME: Note the queries aren't currently run in a
|
||||||
.txn
|
// transaction, as storing the transaction object and a pooled
|
||||||
.take()
|
// connection in the `Txn` object is complex.
|
||||||
.ok_or(SqliteError::TransactionAlreadyCommitted)?;
|
// https://github.com/taskchampion/taskchampion/pull/206#issuecomment-860336073
|
||||||
t.commit().context("Committing transaction")?;
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user