From a68d89c20d325401585d762e3c34283f5db1654f Mon Sep 17 00:00:00 2001 From: involk-secure-1609 Date: Mon, 13 Oct 2025 15:51:46 +0530 Subject: [PATCH] supports postgres:db_name now Signed-off-by: involk-secure-1609 --- sea-orm-cli/src/commands/generate.rs | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/sea-orm-cli/src/commands/generate.rs b/sea-orm-cli/src/commands/generate.rs index d47a499385..245d9caef0 100644 --- a/sea-orm-cli/src/commands/generate.rs +++ b/sea-orm-cli/src/commands/generate.rs @@ -89,16 +89,20 @@ pub async fn run_generate_command( // Throwing an error if there is no database name since it might be // accepted by the database without it, while we're looking to dump // information from a particular database - let database_name = url - .path_segments() - .unwrap_or_else(|| { - panic!( - "There is no database name as part of the url path: {}", - url.as_str() - ) - }) - .next() - .unwrap(); + let database_name = match url.path_segments() { + None => { + let paths: Vec<&str> = url.path().split('/').collect(); + if paths.len() == 0 { + panic!( + "There is no database name as part of the url path: {}", + url.as_str() + ) + } else { + paths[0] + } + } + Some(mut path_segments) => path_segments.next().unwrap_or_else(|| return ""), + }; // An empty string as the database name is also an error if database_name.is_empty() {