Apply suggestions from code review

Co-authored-by: thesimplekid <tsk@thesimplekid.com>
This commit is contained in:
C
2025-07-26 17:34:55 -03:00
committed by Cesar Rodas
parent fb4c470a9a
commit 99ced01e67
4 changed files with 13 additions and 10 deletions

View File

@@ -21,13 +21,14 @@ pub async fn migrate<C: DatabaseExecutor>(
// Apply each migration if it hasnt been applied yet
for (name, sql) in migrations {
let basename = if let Some((prefix, basename)) = name.split_once(['/', '\\']) {
if prefix != db_prefix {
continue;
let basename = match name.split_once(['/', '\\']) {
Some((prefix, basename)) => {
if prefix != db_prefix {
continue;
}
basename
}
basename
} else {
name
None => name,
};
let is_missing = query("SELECT name FROM migrations WHERE name = :name")?

View File

@@ -37,7 +37,7 @@ pub trait ResourceManager: Debug {
/// Creates a new resource with a given config.
///
/// If `stale` is every set to TRUE it is assumed the resource is no longer valid and it will be
/// If `stale` is ever set to TRUE it is assumed the resource is no longer valid and it will be
/// dropped.
fn new_resource(
config: &Self::Config,

View File

@@ -176,9 +176,11 @@ impl Statement {
} else {
let parts = split_sql_parts(sql)?;
let _ = cache.write().map(|mut cache| {
if let Ok(mut cache) = cache.write() {
cache.insert(sql.to_owned(), (parts.clone(), None));
});
} else {
tracing::warn!("Failed to acquire write lock for SQL statement cache");
}
Ok(Self {
parts,