[Bps-public-commit] dbix-searchbuilder branch, oracle-dsn, created. 1.59-4-g803a00a

Ruslan Zakirov ruz at bestpractical.com
Tue Apr 19 22:41:20 EDT 2011


The branch, oracle-dsn has been created
        at  803a00ad300a01e4ac00f29360bcecd99e7570b4 (commit)

- Log -----------------------------------------------------------------
commit 803a00ad300a01e4ac00f29360bcecd99e7570b4
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Wed Apr 20 06:38:13 2011 +0400

    custom BuildDSN for Oracle
    
    * Oracle never supported dbname=xxx, so use Database as synonim for SID
    * SSL option is useless, as well
    * dbi:Oracle:SID != dbi:Oracle:sid=SID, so use the former when Host
      is not defined.

diff --git a/lib/DBIx/SearchBuilder/Handle/Oracle.pm b/lib/DBIx/SearchBuilder/Handle/Oracle.pm
index de0a6bf..1e4426d 100755
--- a/lib/DBIx/SearchBuilder/Handle/Oracle.pm
+++ b/lib/DBIx/SearchBuilder/Handle/Oracle.pm
@@ -53,6 +53,51 @@ sub Connect  {
     return ($rv); 
 }
 
+=head2 BuildDSN
+
+Customized version of L<DBIx::SearchBuilder::Handle/BuildDSN> method.
+
+Takes additional argument SID. Database argument used unless SID provided.
+Two forms of DSN are generated depending on whether Host defined or not:
+
+    dbi:Oracle:sid=<SID>;host=...[;port=...]
+    dbi:Oracle:<SID>
+
+Read details in documentation for L<DBD::Oracle> module.
+
+=cut
+
+sub BuildDSN {
+    my $self = shift;
+    my %args = (
+        Driver     => undef,
+        Database   => undef,
+        Host       => undef,
+        Port       => undef,
+        SID        => undef,
+        @_
+    );
+    $args{'Driver'} ||= 'Oracle';
+
+# read DBD::Oracle for details, but basicly it supports
+# either 'dbi:Oracle:SID' or 'dbi:Oracle:sid=SID;host=...;[port=...;]'
+# and tests shows that 'dbi:Oracle:SID' != 'dbi:Oracle:sid=SID'
+
+    $args{'SID'} ||= $args{'Database'};
+    my $dsn = "dbi:$args{'Driver'}:";
+    if ( $args{'Host'} ) {
+        $dsn .= "sid=$args{'SID'}"    if $args{'SID'};
+        $dsn .= ";host=$args{'Host'}";
+        $dsn .= ";port=$args{'Port'}" if $args{'Port'};
+    }
+    else {
+        $dsn .= $args{'SID'} if $args{'SID'};
+        $dsn .= ";port=$args{'Port'}" if $args{'Port'};
+    }
+
+    return $self->{'dsn'} = $dsn;
+}
+
 
 =head2 Insert
 

-----------------------------------------------------------------------



More information about the Bps-public-commit mailing list