Skip to content

Commit 9fd8bfa

Browse files
committed
Use service_name instead of sid for Oracle dbname
The goal is to let DBD::Oracle or the SQL*Plus library properly use a SID when it should, since it seems a service name can be a SID, but not the other way around, if I read [this SO answer] corectly. Resolves #22. [this SO answer]: https://stackoverflow.com/a/4650258/79202
1 parent 0c9e8e6 commit 9fd8bfa

File tree

3 files changed

+25
-12
lines changed

3 files changed

+25
-12
lines changed

Changes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
Revision history for Perl extension URI::db.
22

33
0.21
4+
- Changed Oracle database DBI parameter name from `sid` to
5+
`service_name`. Thanks to @vectro for the report (#22).
46

57
0.20 2022-06-20T17:48:44Z
68
- Added URI::cockroach and URI::yugabyte.

lib/URI/oracle.pm

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,8 @@ sub _dbi_param_map {
1010
return (
1111
[ host => scalar $self->host ],
1212
[ port => scalar $self->_port ],
13-
[ sid => scalar $self->dbname ],
13+
[ service_name => scalar $self->dbname ],
1414
);
1515
}
1616

17-
sub dbi_dsn {
18-
my $self = shift;
19-
my $params = $self->_dsn_params;
20-
$params =~ s/sid=// unless $self->host || $self->_port;
21-
return join ':' => 'dbi', $self->dbi_driver, $params
22-
}
23-
2417
1;

t/dbi.t

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -206,14 +206,32 @@ for my $spec (
206206
},
207207
{
208208
uri => 'db:oracle://localhost:33/foo',
209-
dsn => 'dbi:Oracle:host=localhost;port=33;sid=foo',
210-
dbi => [ [host => 'localhost'], [port => 33], [sid => 'foo'] ],
209+
dsn => 'dbi:Oracle:host=localhost;port=33;service_name=foo',
210+
dbi => [ [host => 'localhost'], [port => 33], [service_name => 'foo'] ],
211+
qry => [],
212+
},
213+
{
214+
uri => 'db:oracle://localhost/foo',
215+
dsn => 'dbi:Oracle:host=localhost;service_name=foo',
216+
dbi => [ [host => 'localhost'], [port => undef], [service_name => 'foo'] ],
217+
qry => [],
218+
},
219+
{
220+
uri => 'db:oracle://:42/foo',
221+
dsn => 'dbi:Oracle:port=42;service_name=foo',
222+
dbi => [ [host => ''], [port => 42], [service_name => 'foo'] ],
211223
qry => [],
212224
},
213225
{
214226
uri => 'db:oracle:foo',
215-
dsn => 'dbi:Oracle:foo',
216-
dbi => [ [host => undef], [port => undef], [sid => 'foo'] ],
227+
dsn => 'dbi:Oracle:service_name=foo',
228+
dbi => [ [host => undef], [port => undef], [service_name => 'foo'] ],
229+
qry => [],
230+
},
231+
{
232+
uri => 'db:oracle:///foo',
233+
dsn => 'dbi:Oracle:service_name=foo',
234+
dbi => [ [host => ''], [port => undef], [service_name => 'foo'] ],
217235
qry => [],
218236
},
219237
{

0 commit comments

Comments
 (0)