Skip to content

Conversation

@w1ll-i-code
Copy link

Does your PR solve an issue?

fixes #4063.

This is useful for having a two-phase validation of the queries in the .sqlx/ offline cache directory. cargo build will check that they are still compatible with the code, while the new sqlx revalidate command will check them against the database. This allows the checks to run independently in a CI (and fail early, if a database migration changes things).

Furthermore, this allows the CI to test if a given PR has breaking changes in relation to the destination branch, so its possible to validate that an old instance can still operate on the database after a migration without re-running cargo check or similar for the target branch.

           / -> cargo build (with sqlx in offline mode)                   \
[CI Run] -> setup db -> sqlx revalidate                                    -> [continue with CI]
                     \ -> git checkout <target-branch> -> sqlx revalidate /

Testing

I want to add an integration test for this feature, however that would entail to run cargo check on a project using query macros. This is not present till now for sqlx-cli. I can add it, but I would like to discuss this first.

Other changes

For now I have simply copied the struct for DynQueryData to sqlx-cli. If this is likely to change it could be migrated from sqlx-macros-core to sql-core, however only with some other refactoring (e.g. the struct methods are also tied to macro-core specific types).

Is this a breaking change?

No. This just adds a new sub-command for sqlx-cli.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Test .sqlx/ files without needing source code access.

1 participant