« blib/lib/DBIx/Class/Schema/Loader/Optional/Dependencies.pm
↑ Summary
blib/lib/DBIx/Class/Schema/Loader/DBI.pm »
| 1 | package DBIx::Class::Schema::Loader::DBI::ODBC::ACCESS; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use base 'DBIx::Class::Schema::Loader::DBI::ODBC'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use mro 'c3'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use Try::Tiny; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use namespace::clean; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use DBIx::Class::Schema::Loader::Table (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||
| 11 | 1 | our $VERSION = '0.07053'; | |||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||
| 13 | 1 | __PACKAGE__->mk_group_accessors('simple', qw/ | |||||||||||||||||||||||||||||||||||||||||
| 14 | __ado_connection | ||||||||||||||||||||||||||||||||||||||||||
| 15 | __adox_catalog | ||||||||||||||||||||||||||||||||||||||||||
| 16 | /); | ||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||
| 18 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||
| 20 | DBIx::Class::Schema::Loader::DBI::ODBC::ACCESS - Microsoft Access driver for | ||||||||||||||||||||||||||||||||||||||||||
| 21 | DBIx::Class::Schema::Loader | ||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||
| 23 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||
| 25 | See L<DBIx::Class::Schema::Loader::Base> for usage information. | ||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||
| 27 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||
| 29 | 0 | ▶ | sub _supports_db_schema { 0 } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_supports_db_schema: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||
| 31 | 0 | ▶ | sub _db_path { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_db_path: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 32 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||
| 34 | 0 | $self->schema->storage->dbh->get_info(16); | |||||||||||||||||||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||
| 37 | 0 | ▶ | sub _open_ado_connection { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_open_ado_connection: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||
| 38 | 0 | my ($self, $conn, $user, $pass) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||
| 40 | 0 | my @info = ({ | |||||||||||||||||||||||||||||||||||||||||
| 41 | provider => 'Microsoft.ACE.OLEDB.12.0', | ||||||||||||||||||||||||||||||||||||||||||
| 42 | dsn_extra => 'Persist Security Info=False', | ||||||||||||||||||||||||||||||||||||||||||
| 43 | }, { | ||||||||||||||||||||||||||||||||||||||||||
| 44 | provider => 'Microsoft.Jet.OLEDB.4.0', | ||||||||||||||||||||||||||||||||||||||||||
| 45 | }); | ||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||
| 47 | 0 | my $opened = 0; | |||||||||||||||||||||||||||||||||||||||||
| 48 | 0 | my $exception; | |||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||
| 50 | 0 | for my $info (@info) { | |||||||||||||||||||||||||||||||||||||||||
| 51 | 0 | $conn->{Provider} = $info->{provider}; | |||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | my $dsn = 'Data Source='.($self->_db_path); | |||||||||||||||||||||||||||||||||||||||||
| 54 | 0 | ▶ | $dsn .= ";$info->{dsn_extra}" if exists $info->{dsn_extra}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||
| 56 | 0 | ▶ | try { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 57 | 0 | $conn->Open($dsn, $user, $pass); | |||||||||||||||||||||||||||||||||||||||||
| 58 | 0 | undef $exception; | |||||||||||||||||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | ▶ | catch { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 61 | 0 | $exception = $_; | |||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | ▶ | next if $exception; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | $opened = 1; | |||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||
| 70 | 0 | return ($opened, $exception); | |||||||||||||||||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | ▶ | sub _ado_connection { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_ado_connection: not called CC=15 SCAR=54.8
| |||||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||
| 77 | 0 | ▶ | return $self->__ado_connection if $self->__ado_connection; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | my ($dsn, $user, $pass) = @{ $self->schema->storage->_dbi_connect_info }; | |||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||
| 81 | 0 | my $have_pass = 1; | |||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||
| 83 | 0 | ▶ | if (ref $dsn eq 'CODE') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 84 | 0 | ($dsn, $user, $pass) = $self->_try_infer_connect_info_from_coderef($dsn); | |||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | ▶ | if (not $dsn) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | my $dbh = $self->schema->storage->dbh; | |||||||||||||||||||||||||||||||||||||||||
| 88 | 0 | $dsn = $dbh->{Name}; | |||||||||||||||||||||||||||||||||||||||||
| 89 | 0 | $user = $dbh->{Username}; | |||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | $have_pass = 0; | |||||||||||||||||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||
| 94 | 0 | require Win32::OLE; | |||||||||||||||||||||||||||||||||||||||||
| 95 | 0 | my $conn = Win32::OLE->new('ADODB.Connection'); | |||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | ▶ | $user = '' unless defined $user; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 98 | 0 | ▶ | if ((not $have_pass) && exists $self->_passwords->{$dsn}{$user}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not $have_pass and exists $self->_passwords->{$dsn}{$user}
MC/DC0%0/2
not $have_pass and exists $self->_passwords->{$dsn}{$user}
not $have_pass
exists $self->_passwords->{$dsn}{$user}
Truth table0%0/3
not(A) and B
A= not $have_passB= exists $self->_passwords->{$dsn}{$user}
| |||||||||||||||||||||||||||||||||||||||||||
| 99 | 0 | $pass = $self->_passwords->{$dsn}{$user}; | |||||||||||||||||||||||||||||||||||||||||
| 100 | 0 | $have_pass = 1; | |||||||||||||||||||||||||||||||||||||||||
| 101 | } | ||||||||||||||||||||||||||||||||||||||||||
| 102 | 0 | ▶ | $pass = '' unless defined $pass; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||
| 104 | 0 | my ($opened, $exception) = $self->_open_ado_connection($conn, $user, $pass); | |||||||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||||||||
| 106 | 0 | ▶ | if ((not $opened) && (not $have_pass)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$opened or $have_pass
MC/DC0%0/2
$opened or $have_pass
$opened
$have_pass
Truth table0%0/3
A or B
A= $openedB= $have_pass
| |||||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | ▶ | if (exists $ENV{DBI_PASS}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 108 | 0 | $pass = $ENV{DBI_PASS}; | |||||||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | ($opened, $exception) = $self->_open_ado_connection($conn, $user, $pass); | |||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||
| 112 | 0 | ▶ | if ($opened) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | $self->_passwords->{$dsn}{$user} = $pass; | |||||||||||||||||||||||||||||||||||||||||
| 114 | } | ||||||||||||||||||||||||||||||||||||||||||
| 115 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | print "Enter database password for $user ($dsn): "; | |||||||||||||||||||||||||||||||||||||||||
| 117 | 0 | chomp($pass = <STDIN>); | |||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||
| 119 | 0 | ($opened, $exception) = $self->_open_ado_connection($conn, $user, $pass); | |||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||
| 121 | 0 | ▶ | if ($opened) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 122 | 0 | $self->_passwords->{$dsn}{$user} = $pass; | |||||||||||||||||||||||||||||||||||||||||
| 123 | } | ||||||||||||||||||||||||||||||||||||||||||
| 124 | } | ||||||||||||||||||||||||||||||||||||||||||
| 125 | } | ||||||||||||||||||||||||||||||||||||||||||
| 126 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | print "Enter database password for $user ($dsn): "; | |||||||||||||||||||||||||||||||||||||||||
| 128 | 0 | chomp($pass = <STDIN>); | |||||||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||||||||
| 130 | 0 | ($opened, $exception) = $self->_open_ado_connection($conn, $user, $pass); | |||||||||||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||||||||||||
| 132 | 0 | ▶ | if ($opened) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | $self->_passwords->{$dsn}{$user} = $pass; | |||||||||||||||||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||||||||||||||||
| 135 | } | ||||||||||||||||||||||||||||||||||||||||||
| 136 | } | ||||||||||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | ▶ | if (not $opened) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | die "Failed to open ADO connection: $exception"; | |||||||||||||||||||||||||||||||||||||||||
| 140 | } | ||||||||||||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | $self->__ado_connection($conn); | |||||||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | return $conn; | |||||||||||||||||||||||||||||||||||||||||
| 145 | } | ||||||||||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||||||||||
| 147 | 0 | ▶ | sub _adox_catalog { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_adox_catalog: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 148 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||||||||
| 150 | 0 | ▶ | return $self->__adox_catalog if $self->__adox_catalog; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | require Win32::OLE; | |||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | my $cat = Win32::OLE->new('ADOX.Catalog'); | |||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | $cat->{ActiveConnection} = $self->_ado_connection; | |||||||||||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||||||||||||
| 156 | 0 | $self->__adox_catalog($cat); | |||||||||||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||||||||||
| 158 | 0 | return $cat; | |||||||||||||||||||||||||||||||||||||||||
| 159 | } | ||||||||||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||||||||||
| 161 | 0 | ▶ | sub _adox_column { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_adox_column: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||
| 162 | 0 | my ($self, $table, $col) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||||||||||||
| 164 | 0 | my $col_obj; | |||||||||||||||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||||||||||||||||
| 166 | 0 | my $cols = $self->_adox_catalog->Tables->Item($table->name)->Columns; | |||||||||||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||||||||||||
| 168 | 0 | for my $col_idx (0..$cols->Count-1) { | |||||||||||||||||||||||||||||||||||||||||
| 169 | 0 | $col_obj = $cols->Item($col_idx); | |||||||||||||||||||||||||||||||||||||||||
| 170 | 0 | ▶ | if ($self->preserve_case) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 171 | 0 | ▶ | last if $col_obj->Name eq $col; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 172 | } | ||||||||||||||||||||||||||||||||||||||||||
| 173 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 174 | 0 | ▶ | last if lc($col_obj->Name) eq lc($col); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 175 | } | ||||||||||||||||||||||||||||||||||||||||||
| 176 | } | ||||||||||||||||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||||||||||||||||
| 178 | 0 | return $col_obj; | |||||||||||||||||||||||||||||||||||||||||
| 179 | } | ||||||||||||||||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||||||||||||||||
| 181 | 0 | ▶ | sub rescan { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
rescan: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 182 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||||||||||||||||
| 184 | 0 | ▶ | if ($self->__adox_catalog) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 185 | 0 | $self->__ado_connection(undef); | |||||||||||||||||||||||||||||||||||||||||
| 186 | 0 | $self->__adox_catalog(undef); | |||||||||||||||||||||||||||||||||||||||||
| 187 | } | ||||||||||||||||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||||||||||||||||
| 189 | 0 | return $self->next::method(@_); | |||||||||||||||||||||||||||||||||||||||||
| 190 | } | ||||||||||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||||||||||
| 192 | 0 | ▶ | sub _table_pk_info { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_table_pk_info: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||||||||||||||||
| 193 | 0 | my ($self, $table) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||||||||||||||||
| 195 | 0 | ▶ | return [] if $self->_disable_pk_detection; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||||||||||||||||
| 197 | 0 | my @keydata; | |||||||||||||||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||||||||||||||||
| 199 | 0 | ▶ | my $indexes = try { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 200 | 0 | $self->_adox_catalog->Tables->Item($table->name)->Indexes | |||||||||||||||||||||||||||||||||||||||||
| 201 | } | ||||||||||||||||||||||||||||||||||||||||||
| 202 | 0 | ▶ | catch { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 203 | 0 | warn "Could not retrieve indexes in table '$table', disabling primary key detection: $_\n"; | |||||||||||||||||||||||||||||||||||||||||
| 204 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||
| 205 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||||||||||||||||
| 207 | 0 | ▶ | if (not $indexes) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 208 | 0 | $self->_disable_pk_detection(1); | |||||||||||||||||||||||||||||||||||||||||
| 209 | 0 | return []; | |||||||||||||||||||||||||||||||||||||||||
| 210 | } | ||||||||||||||||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||||||||||||||||
| 212 | 0 | for my $idx_num (0..($indexes->Count-1)) { | |||||||||||||||||||||||||||||||||||||||||
| 213 | 0 | my $idx = $indexes->Item($idx_num); | |||||||||||||||||||||||||||||||||||||||||
| 214 | 0 | ▶ | if ($idx->PrimaryKey) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 215 | 0 | my $cols = $idx->Columns; | |||||||||||||||||||||||||||||||||||||||||
| 216 | 0 | for my $col_idx (0..$cols->Count-1) { | |||||||||||||||||||||||||||||||||||||||||
| 217 | 0 | push @keydata, $self->_lc($cols->Item($col_idx)->Name); | |||||||||||||||||||||||||||||||||||||||||
| 218 | } | ||||||||||||||||||||||||||||||||||||||||||
| 219 | } | ||||||||||||||||||||||||||||||||||||||||||
| 220 | } | ||||||||||||||||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||||||||||||||||
| 222 | 0 | return \@keydata; | |||||||||||||||||||||||||||||||||||||||||
| 223 | } | ||||||||||||||||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||||||||||||||||
| 225 | 0 | ▶ | sub _table_fk_info { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_table_fk_info: not called CC=7 SCAR=40.3
| |||||||||||||||||||||||||||||||||||||||||||
| 226 | 0 | my ($self, $table) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||||||||||||
| 228 | 0 | ▶ | return [] if $self->_disable_fk_detection; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||||||||||||
| 230 | 0 | ▶ | my $keys = try { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 231 | 0 | $self->_adox_catalog->Tables->Item($table->name)->Keys; | |||||||||||||||||||||||||||||||||||||||||
| 232 | } | ||||||||||||||||||||||||||||||||||||||||||
| 233 | 0 | ▶ | catch { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 234 | 0 | warn "Could not retrieve keys in table '$table', disabling relationship detection: $_\n"; | |||||||||||||||||||||||||||||||||||||||||
| 235 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||
| 236 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||||||||||||||||
| 238 | 0 | ▶ | if (not $keys) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 239 | 0 | $self->_disable_fk_detection(1); | |||||||||||||||||||||||||||||||||||||||||
| 240 | 0 | return []; | |||||||||||||||||||||||||||||||||||||||||
| 241 | } | ||||||||||||||||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||||||||||||||||
| 243 | 0 | my @rels; | |||||||||||||||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||||||||||||||||
| 245 | 0 | for my $key_idx (0..($keys->Count-1)) { | |||||||||||||||||||||||||||||||||||||||||
| 246 | 0 | my $key = $keys->Item($key_idx); | |||||||||||||||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||||||||||||||||
| 248 | 0 | ▶ | next unless $key->Type == 2; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||||||||||||||||
| 250 | 0 | my $local_cols = $key->Columns; | |||||||||||||||||||||||||||||||||||||||||
| 251 | 0 | my $remote_table = $key->RelatedTable; | |||||||||||||||||||||||||||||||||||||||||
| 252 | 0 | my (@local_cols, @remote_cols); | |||||||||||||||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||||||||||||||||
| 254 | 0 | for my $col_idx (0..$local_cols->Count-1) { | |||||||||||||||||||||||||||||||||||||||||
| 255 | 0 | my $col = $local_cols->Item($col_idx); | |||||||||||||||||||||||||||||||||||||||||
| 256 | 0 | push @local_cols, $self->_lc($col->Name); | |||||||||||||||||||||||||||||||||||||||||
| 257 | 0 | push @remote_cols, $self->_lc($col->RelatedColumn); | |||||||||||||||||||||||||||||||||||||||||
| 258 | } | ||||||||||||||||||||||||||||||||||||||||||
| 259 | |||||||||||||||||||||||||||||||||||||||||||
| 260 | 0 | ▶ | push @rels, { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 261 | local_columns => \@local_cols, | ||||||||||||||||||||||||||||||||||||||||||
| 262 | remote_columns => \@remote_cols, | ||||||||||||||||||||||||||||||||||||||||||
| 263 | remote_table => DBIx::Class::Schema::Loader::Table->new( | ||||||||||||||||||||||||||||||||||||||||||
| 264 | loader => $self, | ||||||||||||||||||||||||||||||||||||||||||
| 265 | name => $remote_table, | ||||||||||||||||||||||||||||||||||||||||||
| 266 | ($self->db_schema ? ( | ||||||||||||||||||||||||||||||||||||||||||
| 267 | schema => $self->db_schema->[0], | ||||||||||||||||||||||||||||||||||||||||||
| 268 | ignore_schema => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 269 | ) : ()), | ||||||||||||||||||||||||||||||||||||||||||
| 270 | ), | ||||||||||||||||||||||||||||||||||||||||||
| 271 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 272 | } | ||||||||||||||||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||||||||||||||||
| 274 | 0 | return \@rels; | |||||||||||||||||||||||||||||||||||||||||
| 275 | } | ||||||||||||||||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||||||||||||||||
| 277 | 0 | ▶ | sub _columns_info_for { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_columns_info_for: not called CC=19 SCAR=59.4
| |||||||||||||||||||||||||||||||||||||||||||
| 278 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 279 | 0 | my ($table) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||||||||||||||||
| 281 | 0 | my $result = $self->next::method(@_); | |||||||||||||||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||||||||||||||||
| 283 | 0 | ▶ | while (my ($col, $info) = each %$result) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 284 | 0 | my $data_type = $info->{data_type}; | |||||||||||||||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||||||||||||||||
| 286 | 0 | my $col_obj = $self->_adox_column($table, $col); | |||||||||||||||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||||||||||||||||
| 288 | 0 | ▶ | $info->{is_nullable} = ($col_obj->Attributes & 2) == 2 ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||||||||||||||||
| 290 | 0 | ▶ | if ($data_type eq 'counter') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 8 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 291 | 0 | $info->{data_type} = 'integer'; | |||||||||||||||||||||||||||||||||||||||||
| 292 | 0 | $info->{is_auto_increment} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 293 | 0 | delete $info->{size}; | |||||||||||||||||||||||||||||||||||||||||
| 294 | } | ||||||||||||||||||||||||||||||||||||||||||
| 295 | elsif ($data_type eq 'longbinary') { | ||||||||||||||||||||||||||||||||||||||||||
| 296 | 0 | $info->{data_type} = 'image'; | |||||||||||||||||||||||||||||||||||||||||
| 297 | 0 | $info->{original}{data_type} = 'longbinary'; | |||||||||||||||||||||||||||||||||||||||||
| 298 | } | ||||||||||||||||||||||||||||||||||||||||||
| 299 | elsif ($data_type eq 'longchar') { | ||||||||||||||||||||||||||||||||||||||||||
| 300 | 0 | $info->{data_type} = 'text'; | |||||||||||||||||||||||||||||||||||||||||
| 301 | 0 | $info->{original}{data_type} = 'longchar'; | |||||||||||||||||||||||||||||||||||||||||
| 302 | } | ||||||||||||||||||||||||||||||||||||||||||
| 303 | elsif ($data_type eq 'double') { | ||||||||||||||||||||||||||||||||||||||||||
| 304 | 0 | $info->{data_type} = 'double precision'; | |||||||||||||||||||||||||||||||||||||||||
| 305 | 0 | $info->{original}{data_type} = 'double'; | |||||||||||||||||||||||||||||||||||||||||
| 306 | } | ||||||||||||||||||||||||||||||||||||||||||
| 307 | elsif ($data_type eq 'guid') { | ||||||||||||||||||||||||||||||||||||||||||
| 308 | 0 | $info->{data_type} = 'uniqueidentifier'; | |||||||||||||||||||||||||||||||||||||||||
| 309 | 0 | $info->{original}{data_type} = 'guid'; | |||||||||||||||||||||||||||||||||||||||||
| 310 | } | ||||||||||||||||||||||||||||||||||||||||||
| 311 | elsif ($data_type eq 'byte') { | ||||||||||||||||||||||||||||||||||||||||||
| 312 | 0 | $info->{data_type} = 'tinyint'; | |||||||||||||||||||||||||||||||||||||||||
| 313 | 0 | $info->{original}{data_type} = 'byte'; | |||||||||||||||||||||||||||||||||||||||||
| 314 | } | ||||||||||||||||||||||||||||||||||||||||||
| 315 | elsif ($data_type eq 'currency') { | ||||||||||||||||||||||||||||||||||||||||||
| 316 | 0 | $info->{data_type} = 'money'; | |||||||||||||||||||||||||||||||||||||||||
| 317 | 0 | $info->{original}{data_type} = 'currency'; | |||||||||||||||||||||||||||||||||||||||||
| 318 | |||||||||||||||||||||||||||||||||||||||||||
| 319 | 0 | ▶ | if (ref $info->{size} eq 'ARRAY' && $info->{size}[0] == 19 && $info->{size}[1] == 4) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
ref $info->{"size"} eq "ARRAY" and $info->{"size"}[0] == 19 and $info->{"size"}[1] == 4
ref $info->{"size"} eq "ARRAY" and $info->{"size"}[0] == 19
MC/DC0%0/3
ref $info->{"size"} eq "ARRAY" and $info->{"size"}[0] == 19 and $info->{"size"}[1] == 4
ref $info->{"size"} eq "ARRAY"
$info->{"size"}[0] == 19
$info->{"size"}[1] == 4
Truth table0%0/4
A and B and C
A= ref $info->{"size"} eq "ARRAY"B= $info->{"size"}[0] == 19C= $info->{"size"}[1] == 4
| |||||||||||||||||||||||||||||||||||||||||||
| 320 | # Actual money column via ODBC, otherwise we pass the sizes on to the ADO driver for | ||||||||||||||||||||||||||||||||||||||||||
| 321 | # decimal columns (which masquerade as money columns...) | ||||||||||||||||||||||||||||||||||||||||||
| 322 | 0 | delete $info->{size}; | |||||||||||||||||||||||||||||||||||||||||
| 323 | } | ||||||||||||||||||||||||||||||||||||||||||
| 324 | } | ||||||||||||||||||||||||||||||||||||||||||
| 325 | elsif ($data_type eq 'decimal') { | ||||||||||||||||||||||||||||||||||||||||||
| 326 | 0 | ▶ | if (ref $info->{size} eq 'ARRAY' && $info->{size}[0] == 18 && $info->{size}[1] == 0) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
ref $info->{"size"} eq "ARRAY" and $info->{"size"}[0] == 18 and $info->{"size"}[1] == 0
ref $info->{"size"} eq "ARRAY" and $info->{"size"}[0] == 18
MC/DC0%0/3
ref $info->{"size"} eq "ARRAY" and $info->{"size"}[0] == 18 and $info->{"size"}[1] == 0
ref $info->{"size"} eq "ARRAY"
$info->{"size"}[0] == 18
$info->{"size"}[1] == 0
Truth table0%0/4
A and B and C
A= ref $info->{"size"} eq "ARRAY"B= $info->{"size"}[0] == 18C= $info->{"size"}[1] == 0
| |||||||||||||||||||||||||||||||||||||||||||
| 327 | 0 | delete $info->{size}; | |||||||||||||||||||||||||||||||||||||||||
| 328 | } | ||||||||||||||||||||||||||||||||||||||||||
| 329 | } | ||||||||||||||||||||||||||||||||||||||||||
| 330 | |||||||||||||||||||||||||||||||||||||||||||
| 331 | # Pass through currency (which can be decimal for ADO.) | ||||||||||||||||||||||||||||||||||||||||||
| 332 | 0 | ▶ | if ($data_type !~ /^(?:(?:var)?(?:char|binary)|decimal)\z/ && $data_type ne 'currency') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not $data_type =~ /^(?:(?:var)?(?:char|binary)|decimal)\z/ and $data_type ne "currency"
MC/DC0%0/2
not $data_type =~ /^(?:(?:var)?(?:char|binary)|decimal)\z/ and $data_type ne "currency"
not $data_type =~ /^(?:(?:var)?(?:char|binary)|decimal)\z/
$data_type ne "currency"
Truth table0%0/3
not(A) and B
A= not $data_type =~ /^(?:(?:var)?(?:char|binary)|decimal)\z/B= $data_type ne "currency"
| |||||||||||||||||||||||||||||||||||||||||||
| 333 | 0 | delete $info->{size}; | |||||||||||||||||||||||||||||||||||||||||
| 334 | } | ||||||||||||||||||||||||||||||||||||||||||
| 335 | } | ||||||||||||||||||||||||||||||||||||||||||
| 336 | |||||||||||||||||||||||||||||||||||||||||||
| 337 | 0 | return $result; | |||||||||||||||||||||||||||||||||||||||||
| 338 | } | ||||||||||||||||||||||||||||||||||||||||||
| 339 | |||||||||||||||||||||||||||||||||||||||||||
| 340 | =head1 SEE ALSO | ||||||||||||||||||||||||||||||||||||||||||
| 341 | |||||||||||||||||||||||||||||||||||||||||||
| 342 | L<DBIx::Class::Schema::Loader>, L<DBIx::Class::Schema::Loader::Base>, | ||||||||||||||||||||||||||||||||||||||||||
| 343 | L<DBIx::Class::Schema::Loader::DBI> | ||||||||||||||||||||||||||||||||||||||||||
| 344 | |||||||||||||||||||||||||||||||||||||||||||
| 345 | =head1 AUTHORS | ||||||||||||||||||||||||||||||||||||||||||
| 346 | |||||||||||||||||||||||||||||||||||||||||||
| 347 | See L<DBIx::Class::Schema::Loader/AUTHORS>. | ||||||||||||||||||||||||||||||||||||||||||
| 348 | |||||||||||||||||||||||||||||||||||||||||||
| 349 | =head1 LICENSE | ||||||||||||||||||||||||||||||||||||||||||
| 350 | |||||||||||||||||||||||||||||||||||||||||||
| 351 | This library is free software; you can redistribute it and/or modify it under | ||||||||||||||||||||||||||||||||||||||||||
| 352 | the same terms as Perl itself. | ||||||||||||||||||||||||||||||||||||||||||
| 353 | |||||||||||||||||||||||||||||||||||||||||||
| 354 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 355 | |||||||||||||||||||||||||||||||||||||||||||
| 356 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 357 | # vim:et sts=4 sw=4 tw=0: | ||||||||||||||||||||||||||||||||||||||||||