Skip to content

Commit

Permalink
fix(rust): fix log level for in-memory SQLite db
Browse files Browse the repository at this point in the history
  • Loading branch information
SanjoDeundiak committed Jan 10, 2025
1 parent ce1abc3 commit 139f38c
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -325,11 +325,17 @@ PRAGMA busy_timeout = 10000;
install_default_drivers();
// SQLite in-memory DB get wiped if there is no connection to it.
// The below setting tries to ensure there is always an open connection
let file_name = random_string();
let options = AnyConnectOptions::from_str(
format!("sqlite:file:{file_name}?mode=memory&cache=shared").as_str(),
)
.map_err(Self::map_sql_err)?
.log_statements(LevelFilter::Trace)
.log_slow_statements(LevelFilter::Trace, Duration::from_secs(1));
let pool_options = PoolOptions::new().idle_timeout(None).max_lifetime(None);

let file_name = random_string();
let pool = pool_options
.connect(format!("sqlite:file:{file_name}?mode=memory&cache=shared").as_str())
.connect_with(options)
.await
.map_err(Self::map_sql_err)?;
Ok(pool)
Expand Down

0 comments on commit 139f38c

Please sign in to comment.