Use cargo check consistently in prepare
#2071
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description of change
Small PR to change
cargo sqlx prepare
to always usecargo check
.Currently,
prepare
invokescargo rustc
by default but switches tocheck
when the--merged
flag is used. This can lead to confusion since certain flags passed tocargo check
will be rejected bycargo rustc
when runningprepare
.The current behaviour also contradicts the
sqlx-cli
README, which states:Which actually fails with the following error:
But passes with
--merged
, regardless of whether the current directory is a workspace root or a sub-crate.cargo sqlx prepare --merged -- --all-targets --all-features
This PR ensures it works with or without
--merged
.When the working directory is a crate in a workspace, it still only builds the queries for it and not the entire workspace.
Is there any reason to retain the behaviour of using
rustc
directly? Edit: does this negatively affect plans for #1706?This arose from the following comment thread: #2069 (comment)
Alternative: update the documentation/README.md to specify
--merged
must be used to combine the queries of multiple targets, even when in a single crate.P.S. sorry for spamming PRs.
Type of change
Bug fix to match the intended behaviour, but might technically be a breaking change as it changes which flags are accepted or not.
How the change has been tested
cd sqlx-cli && cargo test
and runningcargo sqlx prepare -- --all-targets --all-features
in a sample project.