Skip to content

Commit

Permalink
fix: pass path with impl AsRef<Path> instead of Pathbuf.
Browse files Browse the repository at this point in the history
when the sqlx_macros_unstable cfg is activated path would have moved otherwise.
  • Loading branch information
JoHaHu committed Mar 12, 2024
1 parent 87cd5c4 commit 46c36a0
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion sqlx-core/src/migrate/source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ pub struct ResolveError {

// FIXME: paths should just be part of `Migration` but we can't add a field backwards compatibly
// since it's `#[non_exhaustive]`.
pub fn resolve_blocking(path: PathBuf) -> Result<Vec<(Migration, PathBuf)>, ResolveError> {
pub fn resolve_blocking(path: impl AsRef<Path>) -> Result<Vec<(Migration, PathBuf)>, ResolveError> {
let path = path.as_ref().to_path_buf();
let mut s = fs::read_dir(&path).map_err(|e| ResolveError {
message: format!("error reading migration directory {}: {e}", path.display()),
source: Some(e),
Expand Down
2 changes: 1 addition & 1 deletion sqlx-macros-core/src/migrate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ pub(crate) fn expand_migrator(path: &Path) -> crate::Result<TokenStream> {
})?;

// Use the same code path to resolve migrations at compile time and runtime.
let migrations = sqlx_core::migrate::resolve_blocking(path)?
let migrations = sqlx_core::migrate::resolve_blocking(&path)?
.into_iter()
.map(|(migration, path)| QuoteMigration { migration, path });

Expand Down

0 comments on commit 46c36a0

Please sign in to comment.