X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FSchema%2FLoader%2FDBI%2FOracle.pm;h=1a8d8171443cc7d25ada36f29ca87bde4eba8e30;hb=ca7feebf8b6e7c50fe330f505ea5e9056a407f59;hp=3be38e2977029db59155f2d665930d5e4e23145b;hpb=fbc9e19665eb41c3ada2166c37e0ba6eaaea515d;p=dbsrgits%2FDBIx-Class-Schema-Loader.git diff --git a/lib/DBIx/Class/Schema/Loader/DBI/Oracle.pm b/lib/DBIx/Class/Schema/Loader/DBI/Oracle.pm index 3be38e2..1a8d817 100644 --- a/lib/DBIx/Class/Schema/Loader/DBI/Oracle.pm +++ b/lib/DBIx/Class/Schema/Loader/DBI/Oracle.pm @@ -1,6 +1,4 @@ -package # hide from pause/cpan for now, as there's a permissions - # issue and it's screwing the rest of the package - DBIx::Class::Schema::Loader::DBI::Oracle; +package DBIx::Class::Schema::Loader::DBI::Oracle; use strict; use warnings; @@ -8,7 +6,7 @@ use base 'DBIx::Class::Schema::Loader::DBI'; use Carp::Clan qw/^DBIx::Class/; use Class::C3; -our $VERSION = '0.04004'; +our $VERSION = '0.05000'; =head1 NAME @@ -38,18 +36,20 @@ 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', {}); -sub _table_columns { - my ($self, $table) = @_; + $self->{db_schema} ||= $current_schema; - my $dbh = $self->schema->storage->dbh; + if (lc($self->db_schema) ne lc($current_schema)) { + $dbh->do('ALTER SESSION SET current_schema=' . $self->db_schema); + } +} - my $sth = $dbh->prepare($self->schema->storage->sql_maker->select($table, undef, \'1 = 0')); - $sth->execute; - return \@{$sth->{NAME_lc}}; +sub _table_as_sql { + my ($self, $table) = @_; + + return $self->_quote_table_name($table); } sub _tables_list { @@ -70,7 +70,7 @@ sub _tables_list { push @tables, $1 if $table =~ /\A(\w+)\z/; } - return @tables; + return $self->_filter_tables(@tables); } sub _table_uniq_info { @@ -80,14 +80,14 @@ sub _table_uniq_info { my $sth = $dbh->prepare_cached( q{ - 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' - ORDER BY ucc.position + SELECT constraint_name, acc.column_name + FROM all_constraints JOIN all_cons_columns acc USING (constraint_name) + 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]; @@ -123,6 +123,31 @@ sub _columns_info_for { return $self->next::method(uc $table); } +sub _extra_column_info { + my ($self, $info) = @_; + my %extra_info; + + my ($table, $column) = @$info{qw/TABLE_NAME COLUMN_NAME/}; + + my $dbh = $self->schema->storage->dbh; + my $sth = $dbh->prepare_cached( + q{ + SELECT COUNT(*) + FROM all_triggers ut JOIN all_trigger_cols atc USING (trigger_name) + WHERE atc.table_name = ? AND atc.column_name = ? + AND column_usage LIKE '%NEW%' AND column_usage LIKE '%OUT%' + AND trigger_type = 'BEFORE EACH ROW' AND triggering_event LIKE '%INSERT%' + }, + {}, 1); + + $sth->execute($table, $column); + if ($sth->fetchrow_array) { + $extra_info{is_auto_increment} = 1; + } + + return \%extra_info; +} + =head1 SEE ALSO L, L, @@ -130,7 +155,12 @@ L =head1 AUTHOR -TSUNODA Kazuya C +See L and L. + +=head1 LICENSE + +This library is free software; you can redistribute it and/or modify it under +the same terms as Perl itself. =cut