1 package # hide from pause/cpan for now, as there's a permissions
2 # issue and it's screwing the rest of the package
3 DBIx::Class::Schema::Loader::DBI::Oracle;
7 use base 'DBIx::Class::Schema::Loader::DBI';
8 use Carp::Clan qw/^DBIx::Class/;
11 our $VERSION = '0.04002';
15 DBIx::Class::Schema::Loader::DBI::Oracle - DBIx::Class::Schema::Loader::DBI
16 Oracle Implementation.
21 use base qw/DBIx::Class::Schema::Loader/;
23 __PACKAGE__->loader_options( debug => 1 );
29 See L<DBIx::Class::Schema::Loader::Base>.
31 This module is considered experimental and not well tested yet.
36 my ($self, $table) = @_;
38 my $dbh = $self->schema->storage->dbh;
40 my $sth = $dbh->prepare($self->schema->storage->sql_maker->select($table, undef, \'1 = 0'));
42 return \@{$sth->{NAME_lc}};
48 my $dbh = $self->schema->storage->dbh;
51 for my $table ( $dbh->tables(undef, $self->db_schema, '%', 'TABLE,VIEW') ) { #catalog, schema, table, type
52 my $quoter = $dbh->get_info(29);
53 $table =~ s/$quoter//g;
55 # remove "user." (schema) prefixes
58 next if $table eq 'PLAN_TABLE';
61 if $table =~ /\A(\w+)\z/;
66 sub _table_uniq_info {
67 my ($self, $table) = @_;
70 my $dbh = $self->schema->storage->dbh;
72 my $sth = $dbh->prepare_cached(
73 qq{SELECT constraint_name, ucc.column_name FROM user_constraints JOIN user_cons_columns ucc USING (constraint_name) WHERE ucc.table_name=? AND constraint_type='U'}
76 $sth->execute(uc $table);
78 while(my $constr = $sth->fetchrow_arrayref) {
79 my $constr_name = $constr->[0];
80 my $constr_def = $constr->[1];
81 $constr_name =~ s/\Q$self->{_quoter}\E//;
82 $constr_def =~ s/\Q$self->{_quoter}\E//;
83 push @{$constr_names{$constr_name}}, lc $constr_def;
86 push(@uniqs, [ lc $_ => $constr_names{$_} ]);
93 my ( $self, $table ) = @_;
94 return $self->SUPER::_table_pk_info(uc $table);
98 my ($self, $table) = @_;
100 my $dbh = $self->schema->storage->dbh;
101 my $sth = $dbh->foreign_key_info( '', '', '', '',
102 $self->db_schema, uc $table );
107 my $i = 1; # for unnamed rels, which hopefully have only 1 column ...
108 while(my $raw_rel = $sth->fetchrow_arrayref) {
109 my $uk_tbl = lc $raw_rel->[2];
110 my $uk_col = lc $raw_rel->[3];
111 my $fk_col = lc $raw_rel->[7];
112 my $relid = ($raw_rel->[11] || ( "__dcsld__" . $i++ ));
113 $uk_tbl =~ s/\Q$self->{_quoter}\E//g;
114 $uk_col =~ s/\Q$self->{_quoter}\E//g;
115 $fk_col =~ s/\Q$self->{_quoter}\E//g;
116 $relid =~ s/\Q$self->{_quoter}\E//g;
117 $rels{$relid}->{tbl} = $uk_tbl;
118 $rels{$relid}->{cols}->{$uk_col} = $fk_col;
122 foreach my $relid (keys %rels) {
124 remote_columns => [ keys %{$rels{$relid}->{cols}} ],
125 local_columns => [ values %{$rels{$relid}->{cols}} ],
126 remote_table => $rels{$relid}->{tbl},
135 L<DBIx::Class::Schema::Loader>, L<DBIx::Class::Schema::Loader::Base>,
136 L<DBIx::Class::Schema::Loader::DBI>
140 TSUNODA Kazuya C<drk@drk7.jp>