new dev release
[dbsrgits/DBIx-Class-Schema-Loader.git] / lib / DBIx / Class / Schema / Loader / DBI / Oracle.pm
index 7d8150b..19be9aa 100644 (file)
@@ -6,7 +6,7 @@ use base 'DBIx::Class::Schema::Loader::DBI';
 use Carp::Clan qw/^DBIx::Class/;
 use Class::C3;
 
-our $VERSION = '0.04999_09';
+our $VERSION = '0.04999_13';
 
 =head1 NAME
 
@@ -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);
+    }
 }
 
 
@@ -80,12 +87,12 @@ sub _table_uniq_info {
         q{
             SELECT constraint_name, acc.column_name
             FROM all_constraints JOIN all_cons_columns acc USING (constraint_name)
-            WHERE acc.table_name=? AND constraint_type='U'
+            WHERE acc.table_name=? and acc.owner = ? AND constraint_type='U'
             ORDER BY acc.position
         },
         {}, 1);
 
-    $sth->execute(uc $table);
+    $sth->execute(uc $table,$self->{db_schema} );
     my %constr_names;
     while(my $constr = $sth->fetchrow_arrayref) {
         my $constr_name = lc $constr->[0];
@@ -153,9 +160,12 @@ L<DBIx::Class::Schema::Loader::DBI>
 
 =head1 AUTHOR
 
-TSUNODA Kazuya C<drk@drk7.jp>
+See L<DBIx::Class::Schema::Loader/AUTHOR> and L<DBIx::Class::Schema::Loader/CONTRIBUTORS>.
+
+=head1 LICENSE
 
-Dagfinn Ilmari MannsÃ¥ker C<ilmari@ilmari.org>
+This library is free software; you can redistribute it and/or modify it under
+the same terms as Perl itself.
 
 =cut