Skip to content

Commit 46e67ca

Browse files
committed
Apply changes from code review
1 parent e5dccdd commit 46e67ca

1 file changed

Lines changed: 10 additions & 13 deletions

File tree

ggsql-jupyter/src/executor.rs

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -98,13 +98,14 @@ pub fn type_name_for_uri(uri: &str) -> String {
9898
return "SQLite".to_string();
9999
}
100100
if let Some(odbc) = uri.strip_prefix("odbc://") {
101-
if odbc.to_lowercase().contains("driver=snowflake") {
102-
return "Snowflake".to_string();
103-
}
104-
if odbc.to_lowercase().contains("driver={postgresql}")
105-
|| odbc.to_lowercase().contains("driver=postgresql")
106-
{
107-
return "PostgreSQL".to_string();
101+
if let Some(driver) = extract_odbc_value(odbc, "driver") {
102+
let lower = driver.to_lowercase();
103+
if lower.contains("snowflake") {
104+
return "Snowflake".to_string();
105+
}
106+
if lower.contains("postgresql") {
107+
return "PostgreSQL".to_string();
108+
}
108109
}
109110
return "ODBC".to_string();
110111
}
@@ -126,12 +127,8 @@ pub fn host_for_uri(uri: &str) -> String {
126127
return path.to_string();
127128
}
128129
if let Some(odbc) = uri.strip_prefix("odbc://") {
129-
// Try to extract server
130-
if let Some(server_start) = odbc.to_lowercase().find("server=") {
131-
let rest = &odbc[server_start + 7..];
132-
if let Some(host) = rest.split(';').next() {
133-
return host.to_string();
134-
}
130+
if let Some(server) = extract_odbc_value(odbc, "server") {
131+
return server;
135132
}
136133
}
137134
uri.to_string()

0 commit comments

Comments
 (0)