Skip to content

fix: resolve path ownership problems when using sqlx_macros_unstable #3236

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions sqlx-core/src/migrate/source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ impl<'s> MigrationSource<'s> for &'s Path {
Box::pin(async move {
let canonical = self.canonicalize()?;
let migrations_with_paths =
crate::rt::spawn_blocking(move || resolve_blocking(canonical)).await?;
crate::rt::spawn_blocking(move || resolve_blocking(&canonical)).await?;

Ok(migrations_with_paths.into_iter().map(|(m, _p)| m).collect())
})
Expand All @@ -54,8 +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> {
let mut s = fs::read_dir(&path).map_err(|e| ResolveError {
pub fn resolve_blocking(path: &Path) -> Result<Vec<(Migration, PathBuf)>, ResolveError> {
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 @@ -103,7 +103,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
Loading