Skip to content
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

Macro parameter for migrations folder causes compile-time error in version 0.8 #3534

Closed
klefevre opened this issue Oct 1, 2024 · 0 comments · Fixed by #3536
Closed

Macro parameter for migrations folder causes compile-time error in version 0.8 #3534

klefevre opened this issue Oct 1, 2024 · 0 comments · Fixed by #3536
Labels

Comments

@klefevre
Copy link

klefevre commented Oct 1, 2024

Bug Description

In version 0.8, there is a regression that prevents us from upgrading due to an error when passing the migrations folder as a parameter to a macro. We use macros to generate our test cases, but the migration parameter triggers a compile-time error.

error: expected string for `false`
  --> src/main.rs:9:26
   |
9  |             #[sqlx::test(migrations = $migrations, fixtures(path = "./fixtures", scripts($fixture)))]
   |                          ^^^^^^^^^^
...
16 |     my_macro!(hello_test3, "./migrations/a", "a");
   |     --------------------------------------------- in this macro invocation

0.8.0, 0.8.1, 0.8.2 give all the same error.

Minimal Reproduction

#[cfg(test)]
mod tests {
    macro_rules! my_macro {
        ($func:ident, $migrations:literal, $fixture:literal) => {
            #[sqlx::test(migrations = $migrations, fixtures(path = "./fixtures", scripts($fixture)))]
            async fn $func(_pool: sqlx::PgPool) {}
        };
    }

    my_macro!(hello_test1, "./migrations/a", "test_foo");
    my_macro!(hello_test2, "./migrations/b", "test_foo");
    my_macro!(hello_test3, "./migrations/a", "test_bar");
    my_macro!(hello_test4, "./migrations/b", "test_bar");
}

Note that both literal and expr have been tested, but neither resolves the issue.

Info

  • SQLx version: 0.8.2
  • SQLx features enabled: postgres
  • Database server and version: Postgres 14
  • Operating system: macOS 14.6.1
  • rustc --version: rustc 1.81.0 (eeb90cda1 2024-09-04)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant