sqlx icon indicating copy to clipboard operation
sqlx copied to clipboard

`cargo sqlx prepare` for workspace member tests

Open Zizico2 opened this issue 1 year ago • 1 comments

Bug Description

Running, cargo sqlx prepare --workspace -- --all-targets --all-features --tests, or cargo sqlx prepare --workspace -- --all-targets --all-features, on the root of a workspace, doesn't prepare the queries in integration tests (tests directory) of the workspace members. The workspace itself is also a binary crate. If I run the same thing inside a specific crate, it works fine.

EDIT: If the workspace root isn't also a crate, it works fine.

Minimal Reproduction

^^^^

Info

  • SQLx version: sqlx-cli-sqlx 0.7.4
  • SQLx features enabled: [REQUIRED]
  • Database server and version: Postgres
  • Operating system: Linux
  • rustc --version: 1.78.0

Zizico2 avatar Jul 22 '24 15:07 Zizico2

Running into the same issue

cargo sqlx prepare --workspace -- --all-targets --all-features --tests ignores some of my workspace crates, but doing it directly cargo sqlx prepare -- --package price-services works, but deletes all my other .json files

jonwalch avatar Oct 08 '24 15:10 jonwalch

I'm having the same issue, yet running cargo sqlx prepare -- --package <package_name> doesn't work as well, in my integration test there is still an error "set DATABASE_URL to use query online or run cargo sqlx prepare to update the query cache", running cargo sqlx prepare -- --tests will panic on the same error.

Jebrano avatar Jun 30 '25 08:06 Jebrano