better handling of db_schema for Oracle, based on (RT#35732)
Rafael Kitover [Tue, 1 Dec 2009 01:43:04 +0000 (01:43 +0000)]
Changes
lib/DBIx/Class/Schema/Loader/DBI/Oracle.pm

diff --git a/Changes b/Changes
index bda06a0..41e4510 100644 (file)
--- a/Changes
+++ b/Changes
@@ -1,5 +1,7 @@
 Revision history for Perl extension DBIx::Class::Schema::Loader
 
+        - better handling of db_schema for Oracle, based on (RT#35732)
+
 0.04999_12  2009-11-30 23:36:14
         - fix MySQL rel introspection with on_connect_call =>
           'set_strict_mode' (RT#52087)
index 59a0dee..21e535e 100644 (file)
@@ -36,7 +36,14 @@ sub _setup {
     $self->next::method(@_);
 
     my $dbh = $self->schema->storage->dbh;
-    $self->{db_schema} ||= $dbh->selectrow_array('SELECT USER FROM DUAL', {});
+
+    my ($current_schema) = $dbh->selectrow_array('SELECT USER FROM DUAL', {});
+
+    $self->{db_schema} ||= $current_schema;
+
+    if (lc($self->db_schema) ne lc($current_schema)) {
+        $dbh->do('ALTER SESSION SET current_schema=' . $self->db_schema);
+    }
 }