File tree 2 files changed +11
-8
lines changed
2 files changed +11
-8
lines changed Original file line number Diff line number Diff line change @@ -518,13 +518,14 @@ function parseOptions(a, b) {
518
518
, auth = ( url . auth || '' ) . split ( ':' )
519
519
, host = o . hostname || o . host || url . hostname || env . PGHOST || 'localhost'
520
520
, port = o . port || url . port || env . PGPORT || 5432
521
+ , user = o . user || o . username || auth [ 0 ] || env . PGUSERNAME || env . PGUSER || osUsername ( )
521
522
522
523
return Object . assign ( {
523
524
host,
524
525
port,
525
526
path : o . path || host . indexOf ( '/' ) > - 1 && host + '/.s.PGSQL.' + port ,
526
- database : o . database || o . db || ( url . pathname || '' ) . slice ( 1 ) || env . PGDATABASE || 'postgres' ,
527
- user : o . user || o . username || auth [ 0 ] || env . PGUSERNAME || env . PGUSER || osUsername ( ) ,
527
+ database : o . database || o . db || ( url . pathname || '' ) . slice ( 1 ) || env . PGDATABASE || user ,
528
+ user : user ,
528
529
pass : o . pass || o . password || auth [ 1 ] || env . PGPASSWORD || '' ,
529
530
max : o . max || url . query . max || 10 ,
530
531
types : o . types || { } ,
Original file line number Diff line number Diff line change @@ -53,13 +53,15 @@ t('Connects with no options', async() => {
53
53
return [ 1 , result ]
54
54
} )
55
55
56
- t ( 'Uses default database without slash' , async ( ) =>
57
- [ 'postgres' , postgres ( 'postgres://localhost' ) . options . database ]
58
- )
56
+ t ( 'Uses default database without slash' , async ( ) => {
57
+ const sql = postgres ( 'postgres://localhost' )
58
+ return [ sql . options . user , sql . options . database ]
59
+ } )
59
60
60
- t ( 'Uses default database with slash' , async ( ) =>
61
- [ 'postgres' , postgres ( 'postgres://localhost/' ) . options . database ]
62
- )
61
+ t ( 'Uses default database with slash' , async ( ) => {
62
+ const sql = postgres ( 'postgres://localhost/' )
63
+ return [ sql . options . user , sql . options . database ]
64
+ } )
63
65
64
66
t ( 'Result is array' , async ( ) =>
65
67
[ true , Array . isArray ( await sql `select 1` ) ]
You can’t perform that action at this time.
0 commit comments