File tree Expand file tree Collapse file tree 2 files changed +11
-8
lines changed
Expand file tree Collapse file tree 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) {
518518 , auth = ( url . auth || '' ) . split ( ':' )
519519 , host = o . hostname || o . host || url . hostname || env . PGHOST || 'localhost'
520520 , port = o . port || url . port || env . PGPORT || 5432
521+ , user = o . user || o . username || auth [ 0 ] || env . PGUSERNAME || env . PGUSER || osUsername ( )
521522
522523 return Object . assign ( {
523524 host,
524525 port,
525526 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 ,
528529 pass : o . pass || o . password || auth [ 1 ] || env . PGPASSWORD || '' ,
529530 max : o . max || url . query . max || 10 ,
530531 types : o . types || { } ,
Original file line number Diff line number Diff line change @@ -53,13 +53,15 @@ t('Connects with no options', async() => {
5353 return [ 1 , result ]
5454} )
5555
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+ } )
5960
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+ } )
6365
6466t ( 'Result is array' , async ( ) =>
6567 [ true , Array . isArray ( await sql `select 1` ) ]
You can’t perform that action at this time.
0 commit comments