radicle: Don't use transactions in cache
The `transaction` method was being used for single queries. This was unnecessary.
This commit is contained in:
parent
9db69a40a6
commit
1d1b9c3d49
|
|
@ -11,7 +11,6 @@ use crate::cob::store;
|
||||||
use crate::cob::{Embed, Label, ObjectId, TypeName};
|
use crate::cob::{Embed, Label, ObjectId, TypeName};
|
||||||
use crate::crypto::Signer;
|
use crate::crypto::Signer;
|
||||||
use crate::prelude::{Did, RepoId};
|
use crate::prelude::{Did, RepoId};
|
||||||
use crate::sql::transaction;
|
|
||||||
use crate::storage::{HasRepoId, ReadRepository, RepositoryError, SignRepository, WriteRepository};
|
use crate::storage::{HasRepoId, ReadRepository, RepositoryError, SignRepository, WriteRepository};
|
||||||
|
|
||||||
use super::{Issue, IssueCounts, IssueId, IssueMut, State};
|
use super::{Issue, IssueCounts, IssueId, IssueMut, State};
|
||||||
|
|
@ -295,21 +294,19 @@ impl Update<Issue> for StoreWriter {
|
||||||
id: &ObjectId,
|
id: &ObjectId,
|
||||||
object: &Issue,
|
object: &Issue,
|
||||||
) -> Result<Self::Out, Self::UpdateError> {
|
) -> Result<Self::Out, Self::UpdateError> {
|
||||||
transaction::<_, UpdateError>(&self.db, move |db| {
|
let mut stmt = self.db.prepare(
|
||||||
let mut stmt = db.prepare(
|
"INSERT INTO issues (id, repo, issue)
|
||||||
"INSERT INTO issues (id, repo, issue)
|
VALUES (?1, ?2, ?3)
|
||||||
VALUES (?1, ?2, ?3)
|
ON CONFLICT DO UPDATE
|
||||||
ON CONFLICT DO UPDATE
|
SET issue = (?3)",
|
||||||
SET issue = (?3)",
|
)?;
|
||||||
)?;
|
|
||||||
|
|
||||||
stmt.bind((1, sql::Value::String(id.to_string())))?;
|
stmt.bind((1, sql::Value::String(id.to_string())))?;
|
||||||
stmt.bind((2, rid))?;
|
stmt.bind((2, rid))?;
|
||||||
stmt.bind((3, sql::Value::String(serde_json::to_string(&object)?)))?;
|
stmt.bind((3, sql::Value::String(serde_json::to_string(&object)?)))?;
|
||||||
stmt.next()?;
|
stmt.next()?;
|
||||||
|
|
||||||
Ok(db.change_count() > 0)
|
Ok(self.db.change_count() > 0)
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -318,17 +315,15 @@ impl Remove<Issue> for StoreWriter {
|
||||||
type RemoveError = sql::Error;
|
type RemoveError = sql::Error;
|
||||||
|
|
||||||
fn remove(&mut self, id: &ObjectId) -> Result<Self::Out, Self::RemoveError> {
|
fn remove(&mut self, id: &ObjectId) -> Result<Self::Out, Self::RemoveError> {
|
||||||
transaction::<_, sql::Error>(&self.db, move |db| {
|
let mut stmt = self.db.prepare(
|
||||||
let mut stmt = db.prepare(
|
"DELETE FROM issues
|
||||||
"DELETE FROM issues
|
WHERE id = ?1",
|
||||||
WHERE id = ?1",
|
)?;
|
||||||
)?;
|
|
||||||
|
|
||||||
stmt.bind((1, sql::Value::String(id.to_string())))?;
|
stmt.bind((1, sql::Value::String(id.to_string())))?;
|
||||||
stmt.next()?;
|
stmt.next()?;
|
||||||
|
|
||||||
Ok(db.change_count() > 0)
|
Ok(self.db.change_count() > 0)
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn remove_all(&mut self, rid: &RepoId) -> Result<Self::Out, Self::RemoveError> {
|
fn remove_all(&mut self, rid: &RepoId) -> Result<Self::Out, Self::RemoveError> {
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,6 @@ use crate::cob::{Label, ObjectId, TypeName};
|
||||||
use crate::crypto::Signer;
|
use crate::crypto::Signer;
|
||||||
use crate::git;
|
use crate::git;
|
||||||
use crate::prelude::RepoId;
|
use crate::prelude::RepoId;
|
||||||
use crate::sql::transaction;
|
|
||||||
use crate::storage::{HasRepoId, ReadRepository, RepositoryError, SignRepository, WriteRepository};
|
use crate::storage::{HasRepoId, ReadRepository, RepositoryError, SignRepository, WriteRepository};
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
|
|
@ -362,21 +361,19 @@ impl Update<Patch> for StoreWriter {
|
||||||
id: &ObjectId,
|
id: &ObjectId,
|
||||||
object: &Patch,
|
object: &Patch,
|
||||||
) -> Result<Self::Out, Self::UpdateError> {
|
) -> Result<Self::Out, Self::UpdateError> {
|
||||||
transaction::<_, UpdateError>(&self.db, move |db| {
|
let mut stmt = self.db.prepare(
|
||||||
let mut stmt = db.prepare(
|
"INSERT INTO patches (id, repo, patch)
|
||||||
"INSERT INTO patches (id, repo, patch)
|
VALUES (?1, ?2, ?3)
|
||||||
VALUES (?1, ?2, ?3)
|
ON CONFLICT DO UPDATE
|
||||||
ON CONFLICT DO UPDATE
|
SET patch = (?3)",
|
||||||
SET patch = (?3)",
|
)?;
|
||||||
)?;
|
|
||||||
|
|
||||||
stmt.bind((1, sql::Value::String(id.to_string())))?;
|
stmt.bind((1, sql::Value::String(id.to_string())))?;
|
||||||
stmt.bind((2, rid))?;
|
stmt.bind((2, rid))?;
|
||||||
stmt.bind((3, sql::Value::String(serde_json::to_string(&object)?)))?;
|
stmt.bind((3, sql::Value::String(serde_json::to_string(&object)?)))?;
|
||||||
stmt.next()?;
|
stmt.next()?;
|
||||||
|
|
||||||
Ok(db.change_count() > 0)
|
Ok(self.db.change_count() > 0)
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -385,17 +382,15 @@ impl Remove<Patch> for StoreWriter {
|
||||||
type RemoveError = sql::Error;
|
type RemoveError = sql::Error;
|
||||||
|
|
||||||
fn remove(&mut self, id: &ObjectId) -> Result<Self::Out, Self::RemoveError> {
|
fn remove(&mut self, id: &ObjectId) -> Result<Self::Out, Self::RemoveError> {
|
||||||
transaction::<_, sql::Error>(&self.db, move |db| {
|
let mut stmt = self.db.prepare(
|
||||||
let mut stmt = db.prepare(
|
"DELETE FROM patches
|
||||||
"DELETE FROM patches
|
WHERE id = ?1",
|
||||||
WHERE id = ?1",
|
)?;
|
||||||
)?;
|
|
||||||
|
|
||||||
stmt.bind((1, sql::Value::String(id.to_string())))?;
|
stmt.bind((1, sql::Value::String(id.to_string())))?;
|
||||||
stmt.next()?;
|
stmt.next()?;
|
||||||
|
|
||||||
Ok(db.change_count() > 0)
|
Ok(self.db.change_count() > 0)
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn remove_all(&mut self, rid: &RepoId) -> Result<Self::Out, Self::RemoveError> {
|
fn remove_all(&mut self, rid: &RepoId) -> Result<Self::Out, Self::RemoveError> {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue