1 package DBIx::Class::Schema::Loader::DBI::Oracle;
5 use base 'DBIx::Class::Schema::Loader::DBI';
6 use Carp::Clan qw/^DBIx::Class/;
9 our $VERSION = '0.03999_01';
13 DBIx::Class::Schema::Loader::DBI::Oracle - DBIx::Class::Schema::Loader::DBI
14 Oracle Implementation.
19 use base qw/DBIx::Class::Schema::Loader/;
21 __PACKAGE__->loader_options( debug => 1 );
27 See L<DBIx::Class::Schema::Loader::Base>.
29 This module is considered experimental and not well tested yet.
34 my ($self, $table) = @_;
36 my $dbh = $self->schema->storage->dbh;
38 my $sth = $dbh->prepare($self->schema->storage->sql_maker->select($table, undef, \'1 = 0'));
40 return \@{$sth->{NAME_lc}};
46 my $dbh = $self->schema->storage->dbh;
49 for my $table ( $dbh->tables(undef, $self->db_schema, '%', 'TABLE,VIEW') ) { #catalog, schema, table, type
50 my $quoter = $dbh->get_info(29);
51 $table =~ s/$quoter//g;
53 # remove "user." (schema) prefixes
56 next if $table eq 'PLAN_TABLE';
59 if $table =~ /\A(\w+)\z/;
64 sub _table_uniq_info {
65 my ($self, $table) = @_;
68 my $dbh = $self->schema->storage->dbh;
70 my $sth = $dbh->prepare_cached(
71 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'}
74 $sth->execute(uc $table);
76 while(my $constr = $sth->fetchrow_arrayref) {
77 my $constr_name = $constr->[0];
78 my $constr_def = $constr->[1];
79 $constr_name =~ s/\Q$self->{_quoter}\E//;
80 $constr_def =~ s/\Q$self->{_quoter}\E//;
81 push @{$constr_names{$constr_name}}, lc $constr_def;
84 push(@uniqs, [ lc $_ => $constr_names{$_} ]);
91 my ( $self, $table ) = @_;
92 return $self->SUPER::_table_pk_info(uc $table);
96 my ($self, $table) = @_;
98 my $dbh = $self->schema->storage->dbh;
99 my $sth = $dbh->foreign_key_info( '', '', '', '',
100 $self->db_schema, uc $table );
105 my $i = 1; # for unnamed rels, which hopefully have only 1 column ...
106 while(my $raw_rel = $sth->fetchrow_arrayref) {
107 my $uk_tbl = lc $raw_rel->[2];
108 my $uk_col = lc $raw_rel->[3];
109 my $fk_col = lc $raw_rel->[7];
110 my $relid = ($raw_rel->[11] || ( "__dcsld__" . $i++ ));
111 $uk_tbl =~ s/\Q$self->{_quoter}\E//g;
112 $uk_col =~ s/\Q$self->{_quoter}\E//g;
113 $fk_col =~ s/\Q$self->{_quoter}\E//g;
114 $relid =~ s/\Q$self->{_quoter}\E//g;
115 $rels{$relid}->{tbl} = $uk_tbl;
116 $rels{$relid}->{cols}->{$uk_col} = $fk_col;
120 foreach my $relid (keys %rels) {
122 remote_columns => [ keys %{$rels{$relid}->{cols}} ],
123 local_columns => [ values %{$rels{$relid}->{cols}} ],
124 remote_table => $rels{$relid}->{tbl},
133 L<DBIx::Class::Schema::Loader>, L<DBIx::Class::Schema::Loader::Base>,
134 L<DBIx::Class::Schema::Loader::DBI>
138 TSUNODA Kazuya C<drk@drk7.jp>