Update sqlx to 0.7

This commit is contained in:
Natsu Kagami 2024-02-04 23:08:53 +01:00
parent a64b9e1157
commit 85954639d7
Signed by: nki
GPG key ID: 55A032EB38B49ADB
24 changed files with 1058 additions and 619 deletions

View file

@ -106,9 +106,9 @@ impl BeatmapMetaCache {
let mut t = self.pool.begin().await?;
for b in &beatmaps {
let mut b = Self::to_cached_beatmap(b, None);
b.store(&mut t).await?;
b.store(&mut *t).await?;
// Save the beatmapset mapping.
b.link_beatmapset(id as i64, &mut t).await?;
b.link_beatmapset(id as i64, &mut *t).await?;
}
t.commit().await?;
}

View file

@ -26,7 +26,7 @@ impl OsuSavedUsers {
/// Get all users
pub async fn all(&self) -> Result<Vec<OsuUser>> {
let mut conn = self.pool.acquire().await?;
model::OsuUser::all(&mut conn)
model::OsuUser::all(&mut *conn)
.map(|v| v.map(OsuUser::from).map_err(Error::from))
.try_collect()
.await
@ -35,7 +35,7 @@ impl OsuSavedUsers {
/// Get an user by their user_id.
pub async fn by_user_id(&self, user_id: UserId) -> Result<Option<OsuUser>> {
let mut conn = self.pool.acquire().await?;
let u = model::OsuUser::by_user_id(user_id.0 as i64, &mut conn)
let u = model::OsuUser::by_user_id(user_id.0 as i64, &mut *conn)
.await?
.map(OsuUser::from);
Ok(u)
@ -44,14 +44,14 @@ impl OsuSavedUsers {
/// Save the given user.
pub async fn save(&self, u: OsuUser) -> Result<()> {
let mut conn = self.pool.acquire().await?;
Ok(model::OsuUser::from(u).store(&mut conn).await?)
Ok(model::OsuUser::from(u).store(&mut *conn).await?)
}
/// Save the given user as a completely new user.
pub async fn new_user(&self, u: OsuUser) -> Result<()> {
let mut t = self.pool.begin().await?;
model::OsuUser::delete(u.user_id.0 as i64, &mut t).await?;
model::OsuUser::from(u).store(&mut t).await?;
model::OsuUser::delete(u.user_id.0 as i64, &mut *t).await?;
model::OsuUser::from(u).store(&mut *t).await?;
t.commit().await?;
Ok(())
}