| 1 | package DB::Introspector::Oracle::Introspector; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use base qw( DB::Introspector::CommonRDB::Introspector ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use constant SINGLE_TABLE_QUERY => | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | q( SELECT LOWER(table_name) AS TABLE_NAME, LOWER(user) AS owner_name | ||||||||||||||||||||||||||||
| 10 | 1 | FROM user_tables WHERE LOWER(table_name)=? ); | |||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 1 | ▶ | use constant ALL_TABLES_QUERY => | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | q( SELECT LOWER(table_name) AS table_name, LOWER(USER) AS owner_name | ||||||||||||||||||||||||||||
| 14 | 1 | FROM user_tables ); | |||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | 0 | ▶ | sub _cached_table { | ||||||||||||||||||||||||||
|
Subroutine
_cached_table: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 18 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 19 | 0 | my $table_name = shift; | |||||||||||||||||||||||||||
| 20 | 0 | return $self->SUPER::_cached_table(lc($table_name)); | |||||||||||||||||||||||||||
| 21 | } | ||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | 0 | ▶ | sub get_single_table_lookup_statement { | ||||||||||||||||||||||||||
|
Subroutine
get_single_table_lookup_statement: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 24 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 25 | 0 | my $table_name = lc(shift); | |||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | 0 | my $sth = $self->dbh->prepare_cached(SINGLE_TABLE_QUERY); | |||||||||||||||||||||||||||
| 28 | 0 | $sth->execute($table_name); | |||||||||||||||||||||||||||
| 29 | 0 | return $sth; | |||||||||||||||||||||||||||
| 30 | } | ||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | 0 | ▶ | sub get_all_tables_lookup_statement { | ||||||||||||||||||||||||||
|
Subroutine
get_all_tables_lookup_statement: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 33 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 34 | 0 | my $sth = $self->dbh->prepare_cached(ALL_TABLES_QUERY); | |||||||||||||||||||||||||||
| 35 | 0 | $sth->execute(); | |||||||||||||||||||||||||||
| 36 | 0 | return $sth; | |||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | 0 | ▶ | sub get_table_class { | ||||||||||||||||||||||||||
|
Subroutine
get_table_class: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 40 | 0 | return q(DB::Introspector::Oracle::Table); | |||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | package DB::Introspector::Oracle::Table; | ||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | 1 | ▶ | use base qw( DB::Introspector::CommonRDB::Table ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | 1 | ▶ | use constant COLUMN_LOOKUP_QUERY => | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 51 | q(SELECT LOWER(column_name) AS NAME, data_type AS TYPE, | ||||||||||||||||||||||||||||
| 52 | DECODE(data_precision, NULL, data_length, data_precision) AS LENGTH | ||||||||||||||||||||||||||||
| 53 | FROM user_tab_columns | ||||||||||||||||||||||||||||
| 54 | 1 | WHERE LOWER(table_name)=?); | |||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | # TODO add support for cross schema references | ||||||||||||||||||||||||||||
| 57 | 1 | ▶ | use constant FOREIGN_KEYS_LOOKUP_QUERY => | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 58 | q(SELECT constraint_name AS name, | ||||||||||||||||||||||||||||
| 59 | DECODE(status,'DISABLED', 0, 1) AS enabled, | ||||||||||||||||||||||||||||
| 60 | DECODE(UPPER(delete_rule), NULL, 'NO ACTION', | ||||||||||||||||||||||||||||
| 61 | 'RESTRICT', 'NO ACTION', | ||||||||||||||||||||||||||||
| 62 | UPPER(delete_rule)) AS delete_rule | ||||||||||||||||||||||||||||
| 63 | FROM user_constraints | ||||||||||||||||||||||||||||
| 64 | WHERE constraint_type='R' | ||||||||||||||||||||||||||||
| 65 | AND LOWER(table_name)=? | ||||||||||||||||||||||||||||
| 66 | 1 | AND owner=r_owner); | |||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | 1 | ▶ | use constant INDEXES_LOOKUP_QUERY => | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 69 | q(SELECT index_name AS name, | ||||||||||||||||||||||||||||
| 70 | uniqueness, | ||||||||||||||||||||||||||||
| 71 | DECODE(index_type, 'FUNCTION-BASED NORMAL', 'FUNCTIONAL', | ||||||||||||||||||||||||||||
| 72 | index_type) AS index_type | ||||||||||||||||||||||||||||
| 73 | FROM user_indexes | ||||||||||||||||||||||||||||
| 74 | 1 | WHERE LOWER(table_name)=?); | |||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | 1 | ▶ | use constant DEPENDENCIES_LOOKUP_QUERY => | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 77 | q(SELECT dep.constraint_name AS name, | ||||||||||||||||||||||||||||
| 78 | dep.table_name AS child_table_name, | ||||||||||||||||||||||||||||
| 79 | DECODE(dep.status,'DISABLED', 0, 1) AS enabled, | ||||||||||||||||||||||||||||
| 80 | DECODE(UPPER(dep.delete_rule), NULL, 'NO ACTION', | ||||||||||||||||||||||||||||
| 81 | 'RESTRICT', 'NO ACTION', | ||||||||||||||||||||||||||||
| 82 | UPPER(dep.delete_rule)) AS delete_rule | ||||||||||||||||||||||||||||
| 83 | FROM user_constraints dep, | ||||||||||||||||||||||||||||
| 84 | user_constraints ent | ||||||||||||||||||||||||||||
| 85 | WHERE dep.constraint_type = 'R' | ||||||||||||||||||||||||||||
| 86 | AND dep.r_constraint_name = ent.constraint_name | ||||||||||||||||||||||||||||
| 87 | 1 | AND LOWER(ent.table_name) = ?); | |||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||
| 89 | 1 | ▶ | use constant PRIMARY_KEY_LOOKUP_QUERY => | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 90 | q(SELECT LOWER ( cols.column_name ) | ||||||||||||||||||||||||||||
| 91 | FROM user_cons_columns cols, | ||||||||||||||||||||||||||||
| 92 | user_constraints c | ||||||||||||||||||||||||||||
| 93 | WHERE cols.constraint_name=c.constraint_name | ||||||||||||||||||||||||||||
| 94 | AND constraint_type='P' | ||||||||||||||||||||||||||||
| 95 | AND LOWER(c.table_name)=? | ||||||||||||||||||||||||||||
| 96 | 1 | ORDER BY position); | |||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||
| 98 | 1 | ▶ | use DB::Introspector::Base::BooleanColumn; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 99 | 1 | ▶ | use DB::Introspector::Base::SpecialColumn; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 100 | 1 | ▶ | use DB::Introspector::Base::IntegerColumn; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 101 | 1 | ▶ | use DB::Introspector::Base::CharColumn; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 102 | 1 | ▶ | use DB::Introspector::Base::CLOBColumn; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 103 | 1 | ▶ | use DB::Introspector::Base::StringColumn; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 104 | 1 | ▶ | use DB::Introspector::Base::DateTimeColumn; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||
| 106 | 1 | ▶ | use constant COLUMN_CLASS_MAPPING => { | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 107 | 'NUMBER' => 'DB::Introspector::Base::IntegerColumn', | ||||||||||||||||||||||||||||
| 108 | 'LONG' => 'DB::Introspector::Base::IntegerColumn', | ||||||||||||||||||||||||||||
| 109 | 'CHAR' => 'DB::Introspector::Base::CharColumn', | ||||||||||||||||||||||||||||
| 110 | 'VARCHAR' => 'DB::Introspector::Base::StringColumn', | ||||||||||||||||||||||||||||
| 111 | 'VARCHAR2' => 'DB::Introspector::Base::StringColumn', | ||||||||||||||||||||||||||||
| 112 | 'DATE' => 'DB::Introspector::Base::DateTimeColumn', | ||||||||||||||||||||||||||||
| 113 | 'TIMESTAMP(6)' => 'DB::Introspector::Base::DateTimeColumn', | ||||||||||||||||||||||||||||
| 114 | 'CLOB' => 'DB::Introspector::Base::CLOBColumn', | ||||||||||||||||||||||||||||
| 115 | 1 | }; | |||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||
| 117 | 0 | ▶ | sub get_primary_key_column_ids { | ||||||||||||||||||||||||||
|
Subroutine
get_primary_key_column_ids: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||
| 118 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||
| 120 | 0 | ▶ | unless( $self->{_primary_key_column_ids} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 121 | 0 | my $sth = | |||||||||||||||||||||||||||
| 122 | $self->_introspector->dbh->prepare_cached(PRIMARY_KEY_LOOKUP_QUERY); | ||||||||||||||||||||||||||||
| 123 | 0 | $sth->execute($self->name); | |||||||||||||||||||||||||||
| 124 | 0 | my @columns = $self->columns; | |||||||||||||||||||||||||||
| 125 | 0 | my @ids; | |||||||||||||||||||||||||||
| 126 | 0 | ▶ | while( my ($column_name) = $sth->fetchrow_array ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 127 | 0 | COLUMN_WALK: foreach my $i (0..$#columns) { | |||||||||||||||||||||||||||
| 128 | 0 | ▶ | if( $columns[$i]->name eq $column_name ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 129 | 0 | push(@ids, $i); | |||||||||||||||||||||||||||
| 130 | 0 | last COLUMN_WALK; | |||||||||||||||||||||||||||
| 131 | } | ||||||||||||||||||||||||||||
| 132 | } | ||||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||
| 134 | 0 | $sth->finish(); | |||||||||||||||||||||||||||
| 135 | 0 | $self->{_primary_key_column_ids} = \@ids; | |||||||||||||||||||||||||||
| 136 | } | ||||||||||||||||||||||||||||
| 137 | 0 | return @{$self->{_primary_key_column_ids}}; | |||||||||||||||||||||||||||
| 138 | } | ||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||
| 140 | 0 | ▶ | sub get_column_lookup_statement { | ||||||||||||||||||||||||||
|
Subroutine
get_column_lookup_statement: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 141 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||
| 143 | 0 | my $sth = $self->_introspector->dbh->prepare_cached(COLUMN_LOOKUP_QUERY); | |||||||||||||||||||||||||||
| 144 | 0 | $sth->execute(lc($self->name)); | |||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||
| 146 | 0 | return $sth; | |||||||||||||||||||||||||||
| 147 | } | ||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||
| 149 | 0 | ▶ | sub get_foreign_keys_lookup_statement { | ||||||||||||||||||||||||||
|
Subroutine
get_foreign_keys_lookup_statement: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 150 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||
| 152 | 0 | my $sth = $self->_introspector->dbh->prepare_cached( | |||||||||||||||||||||||||||
| 153 | FOREIGN_KEYS_LOOKUP_QUERY); | ||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||
| 155 | 0 | $sth->execute(lc($self->name)); | |||||||||||||||||||||||||||
| 156 | 0 | return $sth; | |||||||||||||||||||||||||||
| 157 | } | ||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||
| 159 | 0 | ▶ | sub get_indexes_lookup_statement { | ||||||||||||||||||||||||||
|
Subroutine
get_indexes_lookup_statement: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 160 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||
| 162 | 0 | my $sth = $self->_introspector->dbh->prepare_cached(INDEXES_LOOKUP_QUERY); | |||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||
| 164 | 0 | $sth->execute(lc($self->name)); | |||||||||||||||||||||||||||
| 165 | 0 | return $sth; | |||||||||||||||||||||||||||
| 166 | } | ||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||
| 168 | 0 | ▶ | sub get_dependencies_lookup_statement { | ||||||||||||||||||||||||||
|
Subroutine
get_dependencies_lookup_statement: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 169 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||
| 171 | 0 | my $sth = $self->_introspector->dbh->prepare_cached( | |||||||||||||||||||||||||||
| 172 | DEPENDENCIES_LOOKUP_QUERY); | ||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||
| 174 | 0 | $sth->execute(lc($self->name)); | |||||||||||||||||||||||||||
| 175 | 0 | return $sth; | |||||||||||||||||||||||||||
| 176 | } | ||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||
| 178 | 0 | ▶ | sub get_column_instance { | ||||||||||||||||||||||||||
|
Subroutine
get_column_instance: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||
| 179 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 180 | 0 | my $name = shift; | |||||||||||||||||||||||||||
| 181 | 0 | my $type_name = uc(shift); | |||||||||||||||||||||||||||
| 182 | 0 | my $extra_data = shift; | |||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||
| 184 | 0 | ▶ | my $class = COLUMN_CLASS_MAPPING()->{$type_name} || return; | ||||||||||||||||||||||||||
|
Condition0%0/2
{CHAR => 'DB::Introspector::Base::CharColumn', CLOB => 'DB::Introspector::Base::CLOBColumn', DATE => 'DB::Introspector::Base::DateTimeColumn', LONG => 'DB::Introspector::Base::IntegerColumn', NUMBER => 'DB::Introspector::Base::IntegerColumn', TIMESTAMP(6) => 'DB::Introspector::Base::DateTimeColumn', VARCHAR => 'DB::Introspector::Base::StringColumn', VARCHAR2 => 'DB::Introspector::Base::StringColumn'}->{$type_name} || (return)
MC/DC0%0/1
{CHAR => 'DB::Introspector::Base::CharColumn', CLOB => 'DB::Introspector::Base::CLOBColumn', DATE => 'DB::Introspector::Base::DateTimeColumn', LONG => 'DB::Introspector::Base::IntegerColumn', NUMBER => 'DB::Introspector::Base::IntegerColumn', TIMESTAMP(6) => 'DB::Introspector::Base::DateTimeColumn', VARCHAR => 'DB::Introspector::Base::StringColumn', VARCHAR2 => 'DB::Introspector::Base::StringColumn'}->{$type_name} || (return)
{CHAR => 'DB::Introspector::Base::CharColumn', CLOB => 'DB::Introspector::Base::CLOBColumn', DATE => 'DB::Introspector::Base::DateTimeColumn', LONG => 'DB::Introspector::Base::IntegerColumn', NUMBER => 'DB::Introspector::Base::IntegerColumn', TIMESTAMP(6) => 'DB::Introspector::Base::DateTimeColumn', VARCHAR => 'DB::Introspector::Base::StringColumn', VARCHAR2 => 'DB::Introspector::Base::StringColumn'}->{$type_name}
Truth table0%0/2
A
A= {CHAR => 'DB::Introspector::Base::CharColumn', CLOB => 'DB::Introspector::Base::CLOBColumn', DATE => 'DB::Introspector::Base::DateTimeColumn', LONG => 'DB::Introspector::Base::IntegerColumn', NUMBER => 'DB::Introspector::Base::IntegerColumn', TIMESTAMP(6) => 'DB::Introspector::Base::DateTimeColumn', VARCHAR => 'DB::Introspector::Base::StringColumn', VARCHAR2 => 'DB::Introspector::Base::StringColumn'}->{$type_name}
| |||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||
| 186 | 0 | ▶ | if($class->isa('DB::Introspector::Base::IntegerColumn')) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 187 | # if we are dealing with an Integer then assume that our min and max | ||||||||||||||||||||||||||||
| 188 | # length is dependent on the number of acceptable characters in the | ||||||||||||||||||||||||||||
| 189 | # number | ||||||||||||||||||||||||||||
| 190 | 0 | my $max = '9' x $extra_data->{LENGTH}; | |||||||||||||||||||||||||||
| 191 | 0 | ▶ | if( defined($max) && $max =~ /^\d+$/ ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $max and $max =~ /^\d+$/
MC/DC0%0/2
defined $max and $max =~ /^\d+$/
defined $max
$max =~ /^\d+$/
Truth table0%0/3
A and B
A= defined $maxB= $max =~ /^\d+$/
| |||||||||||||||||||||||||||||
| 192 | 0 | return $class->new($name, -$max, $max); | |||||||||||||||||||||||||||
| 193 | } else { | ||||||||||||||||||||||||||||
| 194 | 0 | return $class->new($name); | |||||||||||||||||||||||||||
| 195 | } | ||||||||||||||||||||||||||||
| 196 | } elsif ($class->isa('DB::Introspector::Base::StringColumn')) { | ||||||||||||||||||||||||||||
| 197 | 0 | return $class->new($name, 0, $extra_data->{LENGTH}); | |||||||||||||||||||||||||||
| 198 | } else { | ||||||||||||||||||||||||||||
| 199 | 0 | return $class->new($name); | |||||||||||||||||||||||||||
| 200 | } | ||||||||||||||||||||||||||||
| 201 | } | ||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||
| 203 | 0 | ▶ | sub get_foreign_key_class { | ||||||||||||||||||||||||||
|
Subroutine
get_foreign_key_class: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 204 | 0 | return q(DB::Introspector::Oracle::ForeignKey); | |||||||||||||||||||||||||||
| 205 | } | ||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||
| 207 | 0 | ▶ | sub get_index_class { | ||||||||||||||||||||||||||
|
Subroutine
get_index_class: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 208 | 0 | return q(DB::Introspector::Oracle::Index); | |||||||||||||||||||||||||||
| 209 | } | ||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||
| 211 | 0 | ▶ | sub get_functional_index_class { | ||||||||||||||||||||||||||
|
Subroutine
get_functional_index_class: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 212 | 0 | return q(DB::Introspector::Oracle::FunctionalIndex); | |||||||||||||||||||||||||||
| 213 | } | ||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||
| 215 | package DB::Introspector::Oracle::ForeignKey; | ||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||
| 217 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||
| 219 | 1 | ▶ | use base qw( DB::Introspector::CommonRDB::ForeignKey ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||
| 221 | 1 | ▶ | use constant LOCAL_COLUMN_NAME_QUERY => | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 222 | q(SELECT LOWER(column_name) AS NAME FROM user_cons_columns | ||||||||||||||||||||||||||||
| 223 | 1 | WHERE constraint_name=? ORDER BY position); | |||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||
| 225 | 1 | ▶ | use constant FOREIGN_COLUMN_NAME_QUERY => | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 226 | q( SELECT /*+first_rows*/ LOWER(column_name) AS name | ||||||||||||||||||||||||||||
| 227 | FROM user_constraints u, | ||||||||||||||||||||||||||||
| 228 | user_cons_columns c | ||||||||||||||||||||||||||||
| 229 | WHERE c.constraint_name=u.r_constraint_name | ||||||||||||||||||||||||||||
| 230 | 1 | AND u.constraint_name=? ORDER BY position); | |||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||
| 232 | 1 | ▶ | use constant FOREIGN_TABLE_NAME_QUERY => | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 233 | q(SELECT LOWER(R.TABLE_NAME) AS NAME | ||||||||||||||||||||||||||||
| 234 | FROM USER_CONSTRAINTS R, USER_CONSTRAINTS U | ||||||||||||||||||||||||||||
| 235 | WHERE U.R_CONSTRAINT_NAME=R.CONSTRAINT_NAME | ||||||||||||||||||||||||||||
| 236 | 1 | AND U.CONSTRAINT_NAME=? ); | |||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||
| 238 | 0 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 239 | 0 | my $class = shift; | |||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||
| 241 | 0 | my $self = $class->SUPER::new(@_); | |||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||
| 243 | 0 | my $table = shift; | |||||||||||||||||||||||||||
| 244 | 0 | my $dependency = shift; | |||||||||||||||||||||||||||
| 245 | 0 | my %args = @_; | |||||||||||||||||||||||||||
| 246 | 0 | $self->{'_name'} = $args{'NAME'}; | |||||||||||||||||||||||||||
| 247 | 0 | $self->{'_enabled'} = $args{'ENABLED'}; | |||||||||||||||||||||||||||
| 248 | 0 | $self->{'_delete_rule'} = $args{'DELETE_RULE'}; | |||||||||||||||||||||||||||
| 249 | 0 | return $self; | |||||||||||||||||||||||||||
| 250 | } | ||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||
| 252 | 0 | ▶ | sub delete_rule { | ||||||||||||||||||||||||||
|
Subroutine
delete_rule: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 253 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 254 | 0 | return $self->{'_delete_rule'}; | |||||||||||||||||||||||||||
| 255 | } | ||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||
| 257 | 0 | ▶ | sub enabled { | ||||||||||||||||||||||||||
|
Subroutine
enabled: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 258 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 259 | 0 | return $self->{'_enabled'}; | |||||||||||||||||||||||||||
| 260 | } | ||||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||
| 262 | 0 | ▶ | sub name { | ||||||||||||||||||||||||||
|
Subroutine
name: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 263 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 264 | 0 | return $self->{_name}; | |||||||||||||||||||||||||||
| 265 | } | ||||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||
| 267 | 0 | ▶ | sub get_local_column_name_lookup_statement { | ||||||||||||||||||||||||||
|
Subroutine
get_local_column_name_lookup_statement: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 268 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 269 | 0 | my $sth = $self->local_table->_introspector->dbh->prepare_cached( | |||||||||||||||||||||||||||
| 270 | LOCAL_COLUMN_NAME_QUERY); | ||||||||||||||||||||||||||||
| 271 | 0 | $sth->execute($self->name); | |||||||||||||||||||||||||||
| 272 | 0 | return $sth; | |||||||||||||||||||||||||||
| 273 | } | ||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||
| 275 | 0 | ▶ | sub get_foreign_column_name_lookup_statement { | ||||||||||||||||||||||||||
|
Subroutine
get_foreign_column_name_lookup_statement: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 276 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 277 | 0 | my $sth = $self->local_table->_introspector->dbh->prepare_cached( | |||||||||||||||||||||||||||
| 278 | FOREIGN_COLUMN_NAME_QUERY); | ||||||||||||||||||||||||||||
| 279 | 0 | $sth->execute($self->name); | |||||||||||||||||||||||||||
| 280 | 0 | return $sth; | |||||||||||||||||||||||||||
| 281 | } | ||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||
| 283 | 0 | ▶ | sub get_foreign_table_name_lookup_statement { | ||||||||||||||||||||||||||
|
Subroutine
get_foreign_table_name_lookup_statement: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 284 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 285 | 0 | my $sth = $self->local_table->_introspector->dbh->prepare_cached( | |||||||||||||||||||||||||||
| 286 | FOREIGN_TABLE_NAME_QUERY); | ||||||||||||||||||||||||||||
| 287 | 0 | $sth->execute($self->name); | |||||||||||||||||||||||||||
| 288 | 0 | return $sth; | |||||||||||||||||||||||||||
| 289 | } | ||||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||
| 291 | package DB::Introspector::Oracle::Index; | ||||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||
| 293 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||
| 295 | 1 | ▶ | use base qw( DB::Introspector::CommonRDB::Index ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 296 | 1 | ▶ | use constant UNIQUE => 'UNIQUE'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 297 | |||||||||||||||||||||||||||||
| 298 | 1 | ▶ | use constant COLUMN_NAME_LOOKUP_QUERY => | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 299 | q(SELECT LOWER(column_name) AS name FROM user_ind_columns WHERE index_name=? | ||||||||||||||||||||||||||||
| 300 | 1 | ORDER BY column_position ASC); | |||||||||||||||||||||||||||
| 301 | |||||||||||||||||||||||||||||
| 302 | 0 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 303 | 0 | my $class = shift; | |||||||||||||||||||||||||||
| 304 | 0 | my $table = shift; | |||||||||||||||||||||||||||
| 305 | 0 | my %row = @_; | |||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||
| 307 | 0 | my $self = $class->SUPER::new($table, $row{UNIQUENESS} eq UNIQUE()); | |||||||||||||||||||||||||||
| 308 | 0 | $self->{_name} = $row{NAME}; | |||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||
| 310 | 0 | $self; | |||||||||||||||||||||||||||
| 311 | } | ||||||||||||||||||||||||||||
| 312 | |||||||||||||||||||||||||||||
| 313 | 0 | ▶ | sub name { | ||||||||||||||||||||||||||
|
Subroutine
name: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 314 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 315 | 0 | return $self->{_name}; | |||||||||||||||||||||||||||
| 316 | } | ||||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||
| 318 | 0 | ▶ | sub get_column_name_lookup_statement { | ||||||||||||||||||||||||||
|
Subroutine
get_column_name_lookup_statement: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 319 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 320 | 0 | my $sth = $self->table->_introspector->dbh->prepare_cached( | |||||||||||||||||||||||||||
| 321 | COLUMN_NAME_LOOKUP_QUERY); | ||||||||||||||||||||||||||||
| 322 | 0 | $sth->execute($self->name); | |||||||||||||||||||||||||||
| 323 | 0 | return $sth; | |||||||||||||||||||||||||||
| 324 | } | ||||||||||||||||||||||||||||
| 325 | |||||||||||||||||||||||||||||
| 326 | |||||||||||||||||||||||||||||
| 327 | package DB::Introspector::Oracle::FunctionalIndex; | ||||||||||||||||||||||||||||
| 328 | |||||||||||||||||||||||||||||
| 329 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 330 | |||||||||||||||||||||||||||||
| 331 | 1 | ▶ | use base qw( DB::Introspector::Oracle::Index ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 332 | 1 | ▶ | use constant UNIQUE => 'UNIQUE'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 333 | |||||||||||||||||||||||||||||
| 334 | 1 | ▶ | use constant COLUMN_NAME_LOOKUP_QUERY => | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 335 | q( SELECT co.column_name AS name, | ||||||||||||||||||||||||||||
| 336 | co.column_position AS central_position, | ||||||||||||||||||||||||||||
| 337 | ex.column_position AS expression_position, | ||||||||||||||||||||||||||||
| 338 | ex.column_expression AS expression | ||||||||||||||||||||||||||||
| 339 | FROM user_ind_expressions ex, user_ind_columns co | ||||||||||||||||||||||||||||
| 340 | WHERE ex.index_name = co.index_name | ||||||||||||||||||||||||||||
| 341 | AND ex.index_name = ? | ||||||||||||||||||||||||||||
| 342 | ORDER BY co.column_position ASC | ||||||||||||||||||||||||||||
| 343 | 1 | ); | |||||||||||||||||||||||||||
| 344 | |||||||||||||||||||||||||||||
| 345 | 0 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 346 | 0 | my $class = shift; | |||||||||||||||||||||||||||
| 347 | 0 | my $self = $class->SUPER::new(@_); | |||||||||||||||||||||||||||
| 348 | |||||||||||||||||||||||||||||
| 349 | 0 | $self->{_is_expression} = {}; | |||||||||||||||||||||||||||
| 350 | 0 | $self; | |||||||||||||||||||||||||||
| 351 | } | ||||||||||||||||||||||||||||
| 352 | |||||||||||||||||||||||||||||
| 353 | 0 | ▶ | sub get_column_name_lookup_statement { | ||||||||||||||||||||||||||
|
Subroutine
get_column_name_lookup_statement: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 354 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 355 | 0 | my $sth = $self->table->_introspector->dbh->prepare_cached( | |||||||||||||||||||||||||||
| 356 | COLUMN_NAME_LOOKUP_QUERY); | ||||||||||||||||||||||||||||
| 357 | 0 | $sth->execute($self->name); | |||||||||||||||||||||||||||
| 358 | 0 | return $sth; | |||||||||||||||||||||||||||
| 359 | } | ||||||||||||||||||||||||||||
| 360 | |||||||||||||||||||||||||||||
| 361 | 0 | ▶ | sub column_names { | ||||||||||||||||||||||||||
|
Subroutine
column_names: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||
| 362 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 363 | |||||||||||||||||||||||||||||
| 364 | 0 | ▶ | unless( defined $self->{'column_names'} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 365 | 0 | my $sth = $self->get_column_name_lookup_statement(); | |||||||||||||||||||||||||||
| 366 | |||||||||||||||||||||||||||||
| 367 | 0 | my @column_names; | |||||||||||||||||||||||||||
| 368 | 0 | ▶ | while( my $row = $sth->fetchrow_hashref('NAME_uc') ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 369 | # this means we have an expression | ||||||||||||||||||||||||||||
| 370 | 0 | ▶ | if( $row->{CENTRAL_POSITION} eq $row->{EXPRESSION_POSITION} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 371 | 0 | push(@column_names, $row->{EXPRESSION}); | |||||||||||||||||||||||||||
| 372 | 0 | $self->{_is_expression}{$row->{EXPRESSION}} = 1; | |||||||||||||||||||||||||||
| 373 | } else { | ||||||||||||||||||||||||||||
| 374 | 0 | push(@column_names, $row->{NAME}); | |||||||||||||||||||||||||||
| 375 | } | ||||||||||||||||||||||||||||
| 376 | } | ||||||||||||||||||||||||||||
| 377 | 0 | $sth->finish(); | |||||||||||||||||||||||||||
| 378 | |||||||||||||||||||||||||||||
| 379 | 0 | $self->{'column_names'} = \@column_names; | |||||||||||||||||||||||||||
| 380 | } | ||||||||||||||||||||||||||||
| 381 | |||||||||||||||||||||||||||||
| 382 | 0 | return @{$self->{'column_names'}}; | |||||||||||||||||||||||||||
| 383 | } | ||||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||
| 385 | 0 | ▶ | sub is_expression { | ||||||||||||||||||||||||||
|
Subroutine
is_expression: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 386 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 387 | 0 | my $column_name = shift; | |||||||||||||||||||||||||||
| 388 | 0 | $self->{_is_expression}{$column_name}; | |||||||||||||||||||||||||||
| 389 | } | ||||||||||||||||||||||||||||
| 390 | |||||||||||||||||||||||||||||
| 391 | 1 | 1; | |||||||||||||||||||||||||||