Repository navigation
Conversation
|
Edit: it was running a test with MySQL 5.7 + rustls which is not supported, pushed a commit to conditionally exclude it from the CI like before. |
|
In #2039 I'm actually doing quite a number to the code for the macros right now. Are you okay waiting until I've finished that? I don't recommend basing on it right now because of how much in flux it is though. |
|
Sure, I can certainly try when you're finished! No guarantee though, depending on how large the differences are it might be better to start from scratch and copy pieces over, rather than continue this PR and risk overwriting changes. |
Co-authored-by: Jonas Platte <[email protected]>
2293793 to
1855f0d
Compare
|
👋 Sure! I ended up rewriting several parts since the I'm unsure how popular this change will be. Displaying many Another thing to consider is printing an error/warning when the installed One (hacky) way to achieve this is to have |
Co-authored-by: Austin Bonander <[email protected]>
1855f0d to
2ab1582
Compare
Just one anecdotal point, but the single Another plus is that this removes the need to cache the parsed |
2ab1582 to
2930032
Compare
+1 to this or some form of version checking. Problems due to a version mismatch seem to be a constant source of issues for people |
|
Looks like this automatically got closed from the target branch getting deleted or something along those lines |
|
Oh yeah, I merged |
|
@cycraig looks like I can't do that, sorry. Can you rebase back against |
|
Perhaps when I cut a release I should immediately bump the version number on |
|
Probably my fault for not clicking the "Allow edits and access to secrets by maintainers" checkbox! Opened #2363 targeting |
Description
Continuation of/supersedes #1770 (comment) and #1183.
Overhauls offline query metadata from being saved in a single
sqlx-data.jsonfile, to every query being saved separately in a.sqlxdirectory (either in the package or workspace root depending on the--workspaceflag).E.g.
Changed
Many of the changes are from #1770 and #1183. I updated the previous work on this with the latest changes from the
mainbranch, implemented outstanding things likecargo sqlx prepare --check, and fixed several bugs.sqlx prepareto save queries individually in a.sqlxdirectory.--mergedflag to--workspaceforsqlx prepare.Add offline query support for MSSQL.The file changes look bigger than they are becauseEdit: reverted this change after rebasing onsqlx-macros/src/query/data.rswas split into its own submodule:sqlx-macros/src/query/{mod.rs, offline.rs}.0.7-dev.TODO:
Related issues
Closes #570
Closes #1005
Supersedes #2322
Type of change
Breaking change. Developers will need to install the latest
sqlx-cliand re-runcargo sqlx preparein their projects.How does it work?
Saving offline queries
cargo sqlx prepare, the command will executecargo checkwith theSQLX_OFFLINE_DIRenvironment variable set to<package or workspace>/.sqlx, depending on the--workspaceflag.expand_with_datainsqlx-macrossaves the query metadata to a temporary file, before moving it to theSQLX_OFFLINE_DIRpath (the move/rename operation should be atomic).SQLX_OFFLINE_DIRis not set (either manually or bysqlx prepare), should avoid any race conditions with IDEs building at the same time like cargo sqlx prepare picks up queries from another crate #2049.Note that
SQLX_OFFLINE_DIRcan be set manually socargo checkwithoutcargo sqlx preparecan generate query files---useful for the CI---but the environment variable doesn't override the directories used bysqlx prepareorsqlx prepare --check, should it?I'm concerned about data loss if it's set to another directory andEdit: changed removal behaviour so onlysqlx preparetries to delete it.query-*.jsonfiles are deleted.Loading offline queries
When loading query metadata offline,
expand_inputinsqlx-macroswill check if the query is saved inSQLX_OFFLINE_DIRif set, then<package>/.sqlx, then<workspace>/.sqlx.Checking offline queries
Running
cargo sqlx prepare --checkwill generate queries and place them intarget/sqlx-prepare-checkand compare the contents to<package or workspace>/.sqlx, depending on the--workspaceflag.If there are queries in
target/sqlx-prepare-checkthat aren't in<package or workspace>/.sqlx(indicating new queries were probably added), the command will fail with an error:prepare check failed: .sqlx is missing one or more queries; you should re-run sqlx prepare.If there are unused queries in
<package or workspace>/.sqlxthat aren't intarget/sqlx-prepare-check(indicated old queries were probably removed), the command will succeed with a warning:potentially unused queries found in .sqlx; you may want to re-run sqlx prepare.Finally, it will compare the JSON contents of files in both directories to ensure they match.