[cli] skip checking connection string contains username and host (#851)
This commit is contained in:
parent
65017bdc08
commit
1fc156288e
@ -55,20 +55,8 @@ pub async fn run_generate_command(
|
|||||||
// above
|
// above
|
||||||
let url_username = url.username();
|
let url_username = url.username();
|
||||||
let url_host = url.host_str();
|
let url_host = url.host_str();
|
||||||
|
|
||||||
let is_sqlite = url.scheme() == "sqlite";
|
let is_sqlite = url.scheme() == "sqlite";
|
||||||
|
|
||||||
// Skip checking if it's SQLite
|
|
||||||
if !is_sqlite {
|
|
||||||
// Panic on any that are missing
|
|
||||||
if url_username.is_empty() {
|
|
||||||
panic!("No username was found in the database url");
|
|
||||||
}
|
|
||||||
if url_host.is_none() {
|
|
||||||
panic!("No host was found in the database url");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let tables = match tables {
|
let tables = match tables {
|
||||||
Some(t) => t,
|
Some(t) => t,
|
||||||
_ => "".to_string(),
|
_ => "".to_string(),
|
||||||
@ -461,25 +449,6 @@ mod tests {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
|
||||||
#[should_panic(expected = "No username was found in the database url")]
|
|
||||||
fn test_generate_entity_no_username() {
|
|
||||||
let cli = Cli::parse_from(vec![
|
|
||||||
"sea-orm-cli",
|
|
||||||
"generate",
|
|
||||||
"entity",
|
|
||||||
"--database-url",
|
|
||||||
"mysql://:root@localhost:3306/database",
|
|
||||||
]);
|
|
||||||
|
|
||||||
match cli.command {
|
|
||||||
Commands::Generate { command } => {
|
|
||||||
smol::block_on(run_generate_command(command, cli.verbose)).unwrap();
|
|
||||||
}
|
|
||||||
_ => unreachable!(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[should_panic(expected = "called `Result::unwrap()` on an `Err` value: PoolTimedOut")]
|
#[should_panic(expected = "called `Result::unwrap()` on an `Err` value: PoolTimedOut")]
|
||||||
fn test_generate_entity_no_password() {
|
fn test_generate_entity_no_password() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user