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};
3
3
use sqlx_core:: percent_encoding:: { percent_decode_str, utf8_percent_encode, NON_ALPHANUMERIC } ;
4
4
use sqlx_core:: Url ;
5
5
use std:: net:: IpAddr ;
6
+ use std:: path:: PathBuf ;
6
7
use std:: str:: FromStr ;
7
8
8
9
impl PgConnectOptions {
@@ -87,6 +88,8 @@ impl PgConnectOptions {
87
88
88
89
"password" => options = options. password ( & value) ,
89
90
91
+ "passfile" => options. passfile_paths . insert ( 0 , PathBuf :: from ( & * value) ) ,
92
+
90
93
"application_name" => options = options. application_name ( & value) ,
91
94
92
95
"options" => {
@@ -242,6 +245,20 @@ fn it_parses_password_correctly_from_parameter() {
242
245
assert_eq ! ( Some ( "some_pass" ) , opts. password. as_deref( ) ) ;
243
246
}
244
247
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
+
245
262
#[ test]
246
263
fn it_parses_application_name_correctly_from_parameter ( ) {
247
264
let url = "postgres:///?application_name=some_name" ;
You can’t perform that action at this time.
0 commit comments