macros-core: give SQLX_OFFLINE_DIR from environment precedence (#3962)

We need to be able to supply this variable via the environment when built via
Nix Crane, which uses cargo vendor, which will filter the .sqlx path.  Renaming
is necessary in that case.
This commit is contained in:
Psionic K 2025-08-16 06:31:30 +09:00 committed by GitHub
parent c825bd36b5
commit fb6b13eee2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -124,6 +124,8 @@ fn init_metadata(manifest_dir: &String) -> crate::Result<Metadata> {
.map(|s| s.eq_ignore_ascii_case("true") || s == "1")
.unwrap_or(false);
let offline_dir = env("SQLX_OFFLINE_DIR").ok().or(offline_dir);
let config = Config::try_from_crate_or_default()?;
let database_url = env(config.common.database_url_var()).ok().or(database_url);