@@ -96,9 +96,6 @@ impl Settings {
9696 }
9797
9898 /// Create a new instance of [`Settings`] from the given URL.
99- ///
100- /// The URL must have the `embedded` parameter set to `true` or
101- /// an error will be returned.
10299 pub fn from_url < S : AsRef < str > > ( url : S ) -> Result < Self > {
103100 let parsed_url = match Url :: parse ( url. as_ref ( ) ) {
104101 Ok ( parsed_url) => parsed_url,
@@ -111,18 +108,6 @@ impl Settings {
111108 } ;
112109 let query_parameters: HashMap < String , String > =
113110 parsed_url. query_pairs ( ) . into_owned ( ) . collect ( ) ;
114- let embedded = query_parameters
115- . get ( "embedded" )
116- . map ( |v| v == "true" )
117- . unwrap_or ( false ) ;
118-
119- if !embedded {
120- return Err ( Error :: InvalidUrl {
121- url : url. as_ref ( ) . to_string ( ) ,
122- message : "Url parameter embedded=true not specified" . to_string ( ) ,
123- } ) ;
124- }
125-
126111 let mut settings = Self :: default ( ) ;
127112
128113 if !parsed_url. username ( ) . is_empty ( ) {
@@ -211,13 +196,12 @@ mod tests {
211196 #[ test]
212197 fn test_settings_from_url ( ) -> Result < ( ) > {
213198 let base_url = "postgresql://postgres:password@localhost:5432/test" ;
214- let embedded = "embedded=true" ;
215199 let installation_dir = "installation_dir=/tmp/postgresql" ;
216200 let password_file = "password_file=/tmp/.pgpass" ;
217201 let data_dir = "data_dir=/tmp/data" ;
218202 let temporary = "temporary=false" ;
219203 let timeout = "timeout=10" ;
220- let url = format ! ( "{base_url}?{embedded}&{ installation_dir}&{password_file}&{data_dir}&{temporary}&{temporary}&{timeout}" ) ;
204+ let url = format ! ( "{base_url}?{installation_dir}&{password_file}&{data_dir}&{temporary}&{temporary}&{timeout}" ) ;
221205 let settings = Settings :: from_url ( url) ?;
222206 assert_eq ! ( "postgres" , settings. username) ;
223207 assert_eq ! ( "password" , settings. password) ;
@@ -238,14 +222,8 @@ mod tests {
238222 assert ! ( Settings :: from_url( "^`~" ) . is_err( ) ) ;
239223 }
240224
241- #[ test]
242- fn test_settings_from_url_invalid_embedded ( ) {
243- assert ! ( Settings :: from_url( "postgresql://" ) . is_err( ) ) ;
244- assert ! ( Settings :: from_url( "postgresql://?embedded=false" ) . is_err( ) ) ;
245- }
246-
247225 #[ test]
248226 fn test_settings_from_url_invalid_timeout ( ) {
249- assert ! ( Settings :: from_url( "postgresql://?embedded=true& timeout=foo" ) . is_err( ) ) ;
227+ assert ! ( Settings :: from_url( "postgresql://?timeout=foo" ) . is_err( ) ) ;
250228 }
251229}
0 commit comments