File tree Expand file tree Collapse file tree 1 file changed +17
-5
lines changed
sqlx-core/src/odbc/options Expand file tree Collapse file tree 1 file changed +17
-5
lines changed Original file line number Diff line number Diff line change @@ -32,11 +32,23 @@ impl FromStr for OdbcConnectOptions {
3232 type Err = Error ;
3333
3434 fn from_str ( s : & str ) -> Result < Self , Self :: Err > {
35- // Use full string as ODBC connection string or DSN
36- Ok ( Self {
37- conn_str : s. to_owned ( ) ,
38- log_settings : LogSettings :: default ( ) ,
39- } )
35+ // Accept forms:
36+ // - "odbc:DSN=Name;..." -> strip scheme
37+ // - "odbc:Name" -> interpret as DSN
38+ // - "DSN=Name;..." or full ODBC connection string
39+ let mut t = s. trim ( ) ;
40+ if let Some ( rest) = t. strip_prefix ( "odbc:" ) {
41+ t = rest;
42+ }
43+ let conn_str = if t. contains ( '=' ) {
44+ // Looks like an ODBC key=value connection string
45+ t. to_string ( )
46+ } else {
47+ // Bare DSN name
48+ format ! ( "DSN={}" , t)
49+ } ;
50+
51+ Ok ( Self { conn_str, log_settings : LogSettings :: default ( ) } )
4052 }
4153}
4254
You can’t perform that action at this time.
0 commit comments