fix(macros): don't mutate environment variables#3848
Conversation
|
|
||
| // Check SQLX_OFFLINE_DIR, then local .sqlx, then workspace .sqlx. | ||
| let dirs = [ | ||
| |_: &Metadata| env("SQLX_OFFLINE_DIR").ok().map(PathBuf::from), |
There was a problem hiding this comment.
This line would have made 0.8.5 work. Now that it is not checked, I believe this causes #3961
There was a problem hiding this comment.
I believe you're correct. We only read it from the .env but not the actual process environment: https://github.com/launchbadge/sqlx/blob/24317d5eab40fbc33caf1142946e2f39caad73ea/sqlx-macros-core/src/query/mod.rs#L127
We only actually check the process environment when we go to write the data out: https://github.com/launchbadge/sqlx/blob/24317d5eab40fbc33caf1142946e2f39caad73ea/sqlx-macros-core/src/query/mod.rs#L386
However, while we should fix this for existing users, I think the offline directory should be configurable in the sqlx.toml (#3383).
This PR fixes a regression I created in #3815. Now, environment variables are read or fall back to the
.envfile instead of mutating them before expanding thequerymacro's.Does your PR solve an issue?
fixes #3836