File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed
sqlx-postgres/src/options Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ use crate::{PgConnectOptions, PgSslMode};
33use sqlx_core:: percent_encoding:: { percent_decode_str, utf8_percent_encode, NON_ALPHANUMERIC } ;
44use sqlx_core:: Url ;
55use std:: net:: IpAddr ;
6+ use std:: path:: PathBuf ;
67use std:: str:: FromStr ;
78
89impl PgConnectOptions {
@@ -87,6 +88,8 @@ impl PgConnectOptions {
8788
8889 "password" => options = options. password ( & value) ,
8990
91+ "passfile" => options. passfile_paths . insert ( 0 , PathBuf :: from ( & * value) ) ,
92+
9093 "application_name" => options = options. application_name ( & value) ,
9194
9295 "options" => {
@@ -242,6 +245,20 @@ fn it_parses_password_correctly_from_parameter() {
242245 assert_eq ! ( Some ( "some_pass" ) , opts. password. as_deref( ) ) ;
243246}
244247
248+ #[ test]
249+ fn it_parses_passfile_correctly_from_parameter ( ) {
250+ let url = "postgres:///?passfile=/non%20default/pgpass&passfile=.pgpass" ;
251+ let opts = PgConnectOptions :: from_str ( url) . unwrap ( ) ;
252+
253+ assert_eq ! (
254+ vec![
255+ PathBuf :: from( ".pgpass" ) ,
256+ PathBuf :: from( "/non default/pgpass" ) ,
257+ ] ,
258+ opts. passfile_paths
259+ ) ;
260+ }
261+
245262#[ test]
246263fn it_parses_application_name_correctly_from_parameter ( ) {
247264 let url = "postgres:///?application_name=some_name" ;
You can’t perform that action at this time.
0 commit comments