File tree 2 files changed +40
-7
lines changed
2 files changed +40
-7
lines changed Original file line number Diff line number Diff line change @@ -179,14 +179,19 @@ def _parse_hostlist(hostlist, port):
179
179
port = _validate_port_spec (hostspecs , port )
180
180
181
181
for i , hostspec in enumerate (hostspecs ):
182
- addr , _ , hostspec_port = hostspec .partition (':' )
183
- hosts .append (addr )
182
+ if hostspec .startswith ('/' ):
183
+ hosts .append (hostspec )
184
+ # keep sequence ordering
185
+ hostlist_ports .append (5432 )
186
+ else :
187
+ addr , _ , hostspec_port = hostspec .partition (':' )
188
+ hosts .append (addr )
184
189
185
- if not port :
186
- if hostspec_port :
187
- hostlist_ports .append (int (hostspec_port ))
188
- else :
189
- hostlist_ports .append (default_port [i ])
190
+ if not port :
191
+ if hostspec_port :
192
+ hostlist_ports .append (int (hostspec_port ))
193
+ else :
194
+ hostlist_ports .append (default_port [i ])
190
195
191
196
if not port :
192
197
port = hostlist_ports
Original file line number Diff line number Diff line change @@ -475,6 +475,34 @@ class TestConnectParams(tb.TestCase):
475
475
}
476
476
)
477
477
},
478
+ {
479
+ 'dsn' : 'postgres:///db?host=/cloudsql/'
480
+ 'project:region:instance-name&user=spam' ,
481
+ 'result' : (
482
+ [os .path .join (
483
+ '/cloudsql/project:region:instance-name' ,
484
+ '.s.PGSQL.5432'
485
+ )], {
486
+ 'user' : 'spam' ,
487
+ 'database' : 'db'
488
+ }
489
+ )
490
+ },
491
+ {
492
+ 'dsn' : 'postgres:///db?host=127.0.0.1:5432,/cloudsql/'
493
+ 'project:region:instance-name,localhost:5433&user=spam' ,
494
+ 'result' : (
495
+ [('127.0.0.1' , 5432 ),
496
+ os .path .join (
497
+ '/cloudsql/project:region:instance-name' ,
498
+ '.s.PGSQL.5432'
499
+ ),
500
+ ('localhost' , 5433 )], {
501
+ 'user' : 'spam' ,
502
+ 'database' : 'db'
503
+ }
504
+ )
505
+ },
478
506
]
479
507
480
508
@contextlib .contextmanager
You can’t perform that action at this time.
0 commit comments