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

Running sqlx prepare without Cargo #3555

Open
alexkirsz opened this issue Oct 10, 2024 · 1 comment
Open

Running sqlx prepare without Cargo #3555

alexkirsz opened this issue Oct 10, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@alexkirsz
Copy link

Is your feature request related to a problem? Please describe.

We're using Bazel and rules_rust to build all of our Rust libraries and binaries. We don't use Cargo at all, which means that we don't have any Cargo.toml file to describe our workspace or crates, and as such cargo build cannot compile our project. Everything is defined in BUILD.bazel files instead.

Describe the solution you'd like

Provide a sqlx prepare command that doesn't require being run through Cargo, possibly taking in a .rlib instead and using a solution akin to UniFFI's metadata macros: embed the generated queries within the generated binary or library, and extract it as part of the sqlx prepare command.

Describe alternatives you've considered

Another way to fix this issue would be to provide first-class Bazel support, but that would not scale well to other cargo-less setups.

@alexkirsz alexkirsz added the enhancement New feature or request label Oct 10, 2024
@TheLortex
Copy link

If I understand correctly, running rustc in "check" mode (the same way it's invoked by cargo check) with a few environment variables should be sufficient. cargo sqlx prepare invokes cargo check with SQLX_TMP, SQLX_OFFLINE set to false, and SQLX_OFFLINE_DIR points to the .sqlx folder.

So it should be possible to set up such a rule in Bazel to generate the .sqlx.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants