I have found these related issues/pull requests
None
Description
Running cargo sqlx prepare seems to mark all source files as dirty. This is intentional:
|
// Update the modified timestamp of package files to force a selective recompilation. |
|
for file in touch_paths { |
|
let now = filetime::FileTime::now(); |
|
filetime::set_file_times(&file, now, now) |
|
.with_context(|| format!("Failed to update mtime for {file:?}"))?; |
|
} |
, but it causes some tools to unnecessarily think the file is dirty (e.g. Helix thinks the file needs to be reloaded, file watchers have more noise than needed).
It would be ideal to change so only files using sqlx::query! are touched, better yet if this is limited to files where the query-*.json changes. Alternatively, maybe there could be a CLI flag to opt out of any timestamp changes?cargo::rerun-if-changed=.sqlx could be set in relevant crates instead.
Obviously the better solution here will eventually be rust-lang/rust#99515.
Reproduction steps
Note the timestamp changes:
$ ls -l backend/middle/src/lib.rs
-rw-r--r-- 1 tmgross staff 66430 May 15 07:56 backend/middle/src/lib.rs
$ DATABASE_URL='...' cargo sqlx prepare --workspace
...
Finished `dev` profile [unoptimized + debuginfo] target(s) in 11.35s
query data written to .sqlx in the workspace root; please check this into version control
$ ls -l backend/middle/src/lib.rs
-rw-r--r-- 1 tmgross staff 66430 May 15 07:59 backend/middle/src/lib.rs
The crate here doesn't even use sqlx directly. --workspace isn't needed to reproduce.
SQLx version
0.8.6
Enabled SQLx features
runtime-tokio, mysql
Database server and version
MariaDB 12.0
Operating system
MacOS
Rust version
1.97 nightly
I have found these related issues/pull requests
None
Description
Running
cargo sqlx prepareseems to mark all source files as dirty. This is intentional:sqlx/sqlx-cli/src/prepare.rs
Lines 264 to 269 in 6956cef
It would be ideal to change so only files using
sqlx::query!are touched, better yet if this is limited to files where thequery-*.jsonchanges. Alternatively, maybe there could be a CLI flag to opt out of any timestamp changes?cargo::rerun-if-changed=.sqlxcould be set in relevant crates instead.Obviously the better solution here will eventually be rust-lang/rust#99515.
Reproduction steps
Note the timestamp changes:
The crate here doesn't even use
sqlxdirectly.--workspaceisn't needed to reproduce.SQLx version
0.8.6
Enabled SQLx features
runtime-tokio,mysqlDatabase server and version
MariaDB 12.0
Operating system
MacOS
Rust version
1.97 nightly