diff --git a/backend/windmill-api/src/variables.rs b/backend/windmill-api/src/variables.rs index 46d005bc8c..cca13a7c25 100644 --- a/backend/windmill-api/src/variables.rs +++ b/backend/windmill-api/src/variables.rs @@ -823,6 +823,7 @@ pub async fn get_value_internal<'a, 'e, A: sqlx::Acquire<'e, Database = Postgres if variable.is_expired.unwrap_or(false) && variable.account.is_some() { #[cfg(feature = "oauth2")] { + let tx = db.begin().await?; crate::oauth2_oss::_refresh_token( tx, &variable.path, diff --git a/backend/windmill-common/src/db.rs b/backend/windmill-common/src/db.rs index 61366c5ad2..c25b0f5c6a 100644 --- a/backend/windmill-common/src/db.rs +++ b/backend/windmill-common/src/db.rs @@ -1,7 +1,5 @@ use sqlx::{Acquire, Pool, Postgres, Transaction}; -use crate::db; - pub type DB = Pool; #[derive(Clone, Debug, Hash)] @@ -123,8 +121,6 @@ impl<'c, 'd, T: Authable + Sync> Acquire<'c> for &'c UserDbWithAuthed<'d, T> { } } - - pub struct UserDbWithOptAuthed<'c, T: Authable + Sync> { pub authed: &'c T, pub user_db: Option, @@ -136,7 +132,7 @@ impl<'c, 'd, T: Authable + Sync> Acquire<'c> for &'c UserDbWithOptAuthed<'d, T> type Connection = Transaction<'c, Postgres>; fn acquire(self) -> futures_core::future::BoxFuture<'c, Result> { - Box::pin(async move { + Box::pin(async move { if let Some(db) = &self.user_db { db.clone().begin(self.authed).await } else { @@ -145,11 +141,10 @@ impl<'c, 'd, T: Authable + Sync> Acquire<'c> for &'c UserDbWithOptAuthed<'d, T> }) } - fn begin( self, ) -> futures_core::future::BoxFuture<'c, Result, sqlx::Error>> { - Box::pin(async move { + Box::pin(async move { if let Some(db) = &self.user_db { db.clone().begin(self.authed).await } else { @@ -159,7 +154,6 @@ impl<'c, 'd, T: Authable + Sync> Acquire<'c> for &'c UserDbWithOptAuthed<'d, T> } } - impl UserDB { pub fn new(db: DB) -> Self { Self { db }