mirror of
https://github.com/launchbadge/sqlx.git
synced 2025-12-26 10:09:50 +00:00
fix(sqlx-cli): pass the DATABASE_URL to command spawned for sqlx-macros (#1735)
This commit is contained in:
parent
dfd9cf59f1
commit
feff96c460
@ -24,7 +24,7 @@ struct DataFile {
|
||||
|
||||
pub fn run(url: &str, merge: bool, cargo_args: Vec<String>) -> anyhow::Result<()> {
|
||||
let db_kind = get_db_kind(url)?;
|
||||
let data = run_prepare_step(merge, cargo_args)?;
|
||||
let data = run_prepare_step(url, merge, cargo_args)?;
|
||||
|
||||
if data.is_empty() {
|
||||
println!(
|
||||
@ -54,7 +54,7 @@ pub fn run(url: &str, merge: bool, cargo_args: Vec<String>) -> anyhow::Result<()
|
||||
|
||||
pub fn check(url: &str, merge: bool, cargo_args: Vec<String>) -> anyhow::Result<()> {
|
||||
let db_kind = get_db_kind(url)?;
|
||||
let data = run_prepare_step(merge, cargo_args)?;
|
||||
let data = run_prepare_step(url, merge, cargo_args)?;
|
||||
|
||||
let data_file = File::open("sqlx-data.json").context(
|
||||
"failed to open `sqlx-data.json`; you may need to run `cargo sqlx prepare` first",
|
||||
@ -80,7 +80,7 @@ pub fn check(url: &str, merge: bool, cargo_args: Vec<String>) -> anyhow::Result<
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn run_prepare_step(merge: bool, cargo_args: Vec<String>) -> anyhow::Result<QueryData> {
|
||||
fn run_prepare_step(url: &str, merge: bool, cargo_args: Vec<String>) -> anyhow::Result<QueryData> {
|
||||
anyhow::ensure!(
|
||||
Path::new("Cargo.toml").exists(),
|
||||
r#"Failed to read `Cargo.toml`.
|
||||
@ -126,6 +126,7 @@ hint: This command only works in the manifest directory of a Cargo package."#
|
||||
.args(cargo_args)
|
||||
.env("RUSTFLAGS", rustflags)
|
||||
.env("SQLX_OFFLINE", "false")
|
||||
.env("DATABASE_URL", url)
|
||||
.status()?
|
||||
} else {
|
||||
Command::new(&cargo)
|
||||
@ -141,6 +142,7 @@ hint: This command only works in the manifest directory of a Cargo package."#
|
||||
SystemTime::UNIX_EPOCH.elapsed()?.as_millis()
|
||||
))
|
||||
.env("SQLX_OFFLINE", "false")
|
||||
.env("DATABASE_URL", url)
|
||||
.status()?
|
||||
};
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user