« blib/lib/DBIx/Class/Schema/Loader/DBI/ADO/MS_Jet.pm
↑ Summary
blib/lib/DBIx/Class/Schema/Loader/Base.pm »
| 1 | package DBIx::Class::Schema::Loader::DBI::DB2; | ||||||||||||||||||||||||||||||||||||||||||
| 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 qw/ | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | DBIx::Class::Schema::Loader::DBI::Component::QuotedDefault | ||||||||||||||||||||||||||||||||||||||||||
| 7 | DBIx::Class::Schema::Loader::DBI | ||||||||||||||||||||||||||||||||||||||||||
| 8 | 1 | /; | |||||||||||||||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use mro 'c3'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||
| 11 | 1 | ▶ | use List::Util 'any'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 12 | 1 | ▶ | use namespace::clean; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||
| 14 | 1 | ▶ | use DBIx::Class::Schema::Loader::Table (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||
| 16 | 1 | our $VERSION = '0.07053'; | |||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||
| 18 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||
| 20 | DBIx::Class::Schema::Loader::DBI::DB2 - DBIx::Class::Schema::Loader::DBI DB2 Implementation. | ||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||
| 22 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||
| 24 | See L<DBIx::Class::Schema::Loader> and L<DBIx::Class::Schema::Loader::Base>. | ||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||
| 26 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||
| 28 | 0 | ▶ | sub _system_schemas { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_system_schemas: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 29 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||
| 31 | 0 | return ($self->next::method(@_), qw/ | |||||||||||||||||||||||||||||||||||||||||
| 32 | SYSCAT SYSIBM SYSIBMADM SYSPUBLIC SYSSTAT SYSTOOLS | ||||||||||||||||||||||||||||||||||||||||||
| 33 | /); | ||||||||||||||||||||||||||||||||||||||||||
| 34 | } | ||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||
| 36 | 0 | ▶ | sub _setup { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_setup: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||
| 37 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||
| 39 | 0 | $self->next::method(@_); | |||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||
| 41 | 0 | my $ns = $self->name_sep; | |||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||
| 43 | 0 | ▶ | $self->db_schema([ $self->dbh->selectrow_array(<<"EOF", {}) ]) unless $self->db_schema; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 44 | SELECT CURRENT_SCHEMA FROM sysibm${ns}sysdummy1 | ||||||||||||||||||||||||||||||||||||||||||
| 45 | EOF | ||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||
| 47 | 0 | ▶ | if (not defined $self->preserve_case) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 48 | 0 | $self->preserve_case(0); | |||||||||||||||||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||||||||||||||||
| 50 | elsif ($self->preserve_case) { | ||||||||||||||||||||||||||||||||||||||||||
| 51 | 0 | $self->schema->storage->sql_maker->quote_char('"'); | |||||||||||||||||||||||||||||||||||||||||
| 52 | 0 | $self->schema->storage->sql_maker->name_sep($ns); | |||||||||||||||||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||
| 56 | 0 | ▶ | sub _table_uniq_info { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_table_uniq_info: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||
| 57 | 0 | my ($self, $table) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | my @uniqs; | |||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||
| 61 | 0 | ▶ | my $sth = $self->{_cache}->{db2_uniq} ||= $self->dbh->prepare(<<'EOF'); | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$self->{"_cache"}{"db2_uniq"} ||= $self->dbh->prepare("SELECT kcu.colname, kcu.constname, kcu.colseq\nFROM syscat.tabconst as tc\nJOIN syscat.keycoluse as kcu\n ON tc.constname = kcu.constname\n AND tc.tabschema = kcu.tabschema\n AND tc.tabname = kcu.tabname\nWHERE tc.tabschema = ? and tc.tabname = ? and tc.type = 'U'\n")
MC/DC0%0/2
$self->{"_cache"}{"db2_uniq"} ||= $self->dbh->prepare("SELECT kcu.colname, kcu.constname, kcu.colseq\nFROM syscat.tabconst as tc\nJOIN syscat.keycoluse as kcu\n ON tc.constname = kcu.constname\n AND tc.tabschema = kcu.tabschema\n AND tc.tabname = kcu.tabname\nWHERE tc.tabschema = ? and tc.tabname = ? and tc.type = 'U'\n")
$self->{"_cache"}{"db2_uniq"}
$self->dbh->prepare("SELECT kcu.colname, kcu.constname, kcu.colseq\nFROM syscat.tabconst as tc\nJOIN syscat.keycoluse as kcu\n ON tc.constname = kcu.constname\n AND tc.tabschema = kcu.tabschema\n AND tc.tabname = kcu.tabname\nWHERE tc.tabschema = ? and tc.tabname = ? and tc.type = 'U'\n")
Truth table0%0/3
A ||= B
A= $self->{"_cache"}{"db2_uniq"}B= $self->dbh->prepare("SELECT kcu.colname, kcu.constname, kcu.colseq\nFROM syscat.tabconst as tc\nJOIN syscat.keycoluse as kcu\n ON tc.constname = kcu.constname\n AND tc.tabschema = kcu.tabschema\n AND tc.tabname = kcu.tabname\nWHERE tc.tabschema = ? and tc.tabname = ? and tc.type = 'U'\n")
| |||||||||||||||||||||||||||||||||||||||||||
| 62 | SELECT kcu.colname, kcu.constname, kcu.colseq | ||||||||||||||||||||||||||||||||||||||||||
| 63 | FROM syscat.tabconst as tc | ||||||||||||||||||||||||||||||||||||||||||
| 64 | JOIN syscat.keycoluse as kcu | ||||||||||||||||||||||||||||||||||||||||||
| 65 | ON tc.constname = kcu.constname | ||||||||||||||||||||||||||||||||||||||||||
| 66 | AND tc.tabschema = kcu.tabschema | ||||||||||||||||||||||||||||||||||||||||||
| 67 | AND tc.tabname = kcu.tabname | ||||||||||||||||||||||||||||||||||||||||||
| 68 | WHERE tc.tabschema = ? and tc.tabname = ? and tc.type = 'U' | ||||||||||||||||||||||||||||||||||||||||||
| 69 | EOF | ||||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||
| 71 | 0 | $sth->execute($table->schema, $table->name); | |||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||
| 73 | 0 | my %keydata; | |||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | ▶ | while(my $row = $sth->fetchrow_arrayref) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | my ($col, $constname, $seq) = @$row; | |||||||||||||||||||||||||||||||||||||||||
| 76 | 0 | push(@{$keydata{$constname}}, [ $seq, $self->_lc($col) ]); | |||||||||||||||||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | foreach my $keyname (sort keys %keydata) { | |||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | my @ordered_cols = map { $_->[1] } sort { $a->[0] <=> $b->[0] } | |||||||||||||||||||||||||||||||||||||||||
| 80 | 0 | @{$keydata{$keyname}}; | |||||||||||||||||||||||||||||||||||||||||
| 81 | 0 | push(@uniqs, [ $keyname => \@ordered_cols ]); | |||||||||||||||||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||
| 84 | 0 | $sth->finish; | |||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | return \@uniqs; | |||||||||||||||||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||
| 89 | 0 | ▶ | sub _table_fk_info { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_table_fk_info: not called CC=8 SCAR=42.8
| |||||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | my ($self, $table) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||
| 92 | 0 | ▶ | my $sth = $self->{_cache}->{db2_fk} ||= $self->dbh->prepare(<<'EOF'); | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$self->{"_cache"}{"db2_fk"} ||= $self->dbh->prepare("SELECT tc.constname, sr.reftabschema, sr.reftabname,\n kcu.colname, rkcu.colname, kcu.colseq,\n sr.deleterule, sr.updaterule\nFROM syscat.tabconst tc\nJOIN syscat.keycoluse kcu\n ON tc.constname = kcu.constname\n AND tc.tabschema = kcu.tabschema\n AND tc.tabname = kcu.tabname\nJOIN syscat.references sr\n ON tc.constname = sr.constname\n AND tc.tabschema = sr.tabschema\n AND tc.tabname = sr.tabname\nJOIN syscat.keycoluse rkcu\n ON sr.refkeyname = rkcu.constname\n AND sr.reftabschema = rkcu.tabschema\n AND sr.reftabname = rkcu.tabname\n AND kcu.colseq = rkcu.colseq\nWHERE tc.tabschema = ?\n AND tc.tabname = ?\n AND tc.type = 'F';\n")
MC/DC0%0/2
$self->{"_cache"}{"db2_fk"} ||= $self->dbh->prepare("SELECT tc.constname, sr.reftabschema, sr.reftabname,\n kcu.colname, rkcu.colname, kcu.colseq,\n sr.deleterule, sr.updaterule\nFROM syscat.tabconst tc\nJOIN syscat.keycoluse kcu\n ON tc.constname = kcu.constname\n AND tc.tabschema = kcu.tabschema\n AND tc.tabname = kcu.tabname\nJOIN syscat.references sr\n ON tc.constname = sr.constname\n AND tc.tabschema = sr.tabschema\n AND tc.tabname = sr.tabname\nJOIN syscat.keycoluse rkcu\n ON sr.refkeyname = rkcu.constname\n AND sr.reftabschema = rkcu.tabschema\n AND sr.reftabname = rkcu.tabname\n AND kcu.colseq = rkcu.colseq\nWHERE tc.tabschema = ?\n AND tc.tabname = ?\n AND tc.type = 'F';\n")
$self->{"_cache"}{"db2_fk"}
$self->dbh->prepare("SELECT tc.constname, sr.reftabschema, sr.reftabname,\n kcu.colname, rkcu.colname, kcu.colseq,\n sr.deleterule, sr.updaterule\nFROM syscat.tabconst tc\nJOIN syscat.keycoluse kcu\n ON tc.constname = kcu.constname\n AND tc.tabschema = kcu.tabschema\n AND tc.tabname = kcu.tabname\nJOIN syscat.references sr\n ON tc.constname = sr.constname\n AND tc.tabschema = sr.tabschema\n AND tc.tabname = sr.tabname\nJOIN syscat.keycoluse rkcu\n ON sr.refkeyname = rkcu.constname\n AND sr.reftabschema = rkcu.tabschema\n AND sr.reftabname = rkcu.tabname\n AND kcu.colseq = rkcu.colseq\nWHERE tc.tabschema = ?\n AND tc.tabname = ?\n AND tc.type = 'F';\n")
Truth table0%0/3
A ||= B
A= $self->{"_cache"}{"db2_fk"}B= $self->dbh->prepare("SELECT tc.constname, sr.reftabschema, sr.reftabname,\n kcu.colname, rkcu.colname, kcu.colseq,\n sr.deleterule, sr.updaterule\nFROM syscat.tabconst tc\nJOIN syscat.keycoluse kcu\n ON tc.constname = kcu.constname\n AND tc.tabschema = kcu.tabschema\n AND tc.tabname = kcu.tabname\nJOIN syscat.references sr\n ON tc.constname = sr.constname\n AND tc.tabschema = sr.tabschema\n AND tc.tabname = sr.tabname\nJOIN syscat.keycoluse rkcu\n ON sr.refkeyname = rkcu.constname\n AND sr.reftabschema = rkcu.tabschema\n AND sr.reftabname = rkcu.tabname\n AND kcu.colseq = rkcu.colseq\nWHERE tc.tabschema = ?\n AND tc.tabname = ?\n AND tc.type = 'F';\n")
| |||||||||||||||||||||||||||||||||||||||||||
| 93 | SELECT tc.constname, sr.reftabschema, sr.reftabname, | ||||||||||||||||||||||||||||||||||||||||||
| 94 | kcu.colname, rkcu.colname, kcu.colseq, | ||||||||||||||||||||||||||||||||||||||||||
| 95 | sr.deleterule, sr.updaterule | ||||||||||||||||||||||||||||||||||||||||||
| 96 | FROM syscat.tabconst tc | ||||||||||||||||||||||||||||||||||||||||||
| 97 | JOIN syscat.keycoluse kcu | ||||||||||||||||||||||||||||||||||||||||||
| 98 | ON tc.constname = kcu.constname | ||||||||||||||||||||||||||||||||||||||||||
| 99 | AND tc.tabschema = kcu.tabschema | ||||||||||||||||||||||||||||||||||||||||||
| 100 | AND tc.tabname = kcu.tabname | ||||||||||||||||||||||||||||||||||||||||||
| 101 | JOIN syscat.references sr | ||||||||||||||||||||||||||||||||||||||||||
| 102 | ON tc.constname = sr.constname | ||||||||||||||||||||||||||||||||||||||||||
| 103 | AND tc.tabschema = sr.tabschema | ||||||||||||||||||||||||||||||||||||||||||
| 104 | AND tc.tabname = sr.tabname | ||||||||||||||||||||||||||||||||||||||||||
| 105 | JOIN syscat.keycoluse rkcu | ||||||||||||||||||||||||||||||||||||||||||
| 106 | ON sr.refkeyname = rkcu.constname | ||||||||||||||||||||||||||||||||||||||||||
| 107 | AND sr.reftabschema = rkcu.tabschema | ||||||||||||||||||||||||||||||||||||||||||
| 108 | AND sr.reftabname = rkcu.tabname | ||||||||||||||||||||||||||||||||||||||||||
| 109 | AND kcu.colseq = rkcu.colseq | ||||||||||||||||||||||||||||||||||||||||||
| 110 | WHERE tc.tabschema = ? | ||||||||||||||||||||||||||||||||||||||||||
| 111 | AND tc.tabname = ? | ||||||||||||||||||||||||||||||||||||||||||
| 112 | AND tc.type = 'F'; | ||||||||||||||||||||||||||||||||||||||||||
| 113 | EOF | ||||||||||||||||||||||||||||||||||||||||||
| 114 | 0 | $sth->execute($table->schema, $table->name); | |||||||||||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | my %rels; | |||||||||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||||||||||
| 118 | 0 | my %rules = ( | |||||||||||||||||||||||||||||||||||||||||
| 119 | A => 'NO ACTION', | ||||||||||||||||||||||||||||||||||||||||||
| 120 | C => 'CASCADE', | ||||||||||||||||||||||||||||||||||||||||||
| 121 | N => 'SET NULL', | ||||||||||||||||||||||||||||||||||||||||||
| 122 | R => 'RESTRICT', | ||||||||||||||||||||||||||||||||||||||||||
| 123 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||||||||||
| 125 | 0 | ▶ | COLS: while (my @row = $sth->fetchrow_array) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 126 | 0 | my ($fk, $remote_schema, $remote_table, $local_col, $remote_col, | |||||||||||||||||||||||||||||||||||||||||
| 127 | $colseq, $delete_rule, $update_rule) = @row; | ||||||||||||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||||||||||||
| 129 | 0 | ▶ | if (not exists $rels{$fk}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 130 | 0 | ▶ | if ($self->db_schema && $self->db_schema->[0] ne '%' | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$self->db_schema and $self->db_schema->[0] ne "%" and not &any(sub {
$_ eq $remote_schema;
}
, @{$self->db_schema;})
$self->db_schema and $self->db_schema->[0] ne "%"
MC/DC0%0/3
$self->db_schema and $self->db_schema->[0] ne "%" and not &any(sub {
$_ eq $remote_schema;
}
, @{$self->db_schema;})
$self->db_schema
$self->db_schema->[0] ne "%"
not &any(sub {
$_ eq $remote_schema;
}
, @{$self->db_schema;})
Truth table0%0/4
A and B and not(C)
A= $self->db_schemaB= $self->db_schema->[0] ne "%"C= not &any(sub {
$_ eq $remote_schema;
}
, @{$self->db_schema;})
| |||||||||||||||||||||||||||||||||||||||||||
| 131 | 0 | ▶ | && (not any { $_ eq $remote_schema } @{ $self->db_schema })) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | next COLS; | |||||||||||||||||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | $rels{$fk}{remote_table} = DBIx::Class::Schema::Loader::Table->new( | |||||||||||||||||||||||||||||||||||||||||
| 137 | loader => $self, | ||||||||||||||||||||||||||||||||||||||||||
| 138 | name => $remote_table, | ||||||||||||||||||||||||||||||||||||||||||
| 139 | schema => $remote_schema, | ||||||||||||||||||||||||||||||||||||||||||
| 140 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 141 | } | ||||||||||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||||||||||
| 143 | 0 | $rels{$fk}{local_columns}[$colseq-1] = $self->_lc($local_col); | |||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | $rels{$fk}{remote_columns}[$colseq-1] = $self->_lc($remote_col); | |||||||||||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||||||||||||
| 146 | $rels{$fk}{attrs} ||= { | ||||||||||||||||||||||||||||||||||||||||||
| 147 | on_delete => $rules{$delete_rule}, | ||||||||||||||||||||||||||||||||||||||||||
| 148 | 0 | ▶ | on_update => $rules{$update_rule}, | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$rels{$fk}{"attrs"} ||= {"on_delete", $rules{$delete_rule}, "on_update", $rules{$update_rule}, "is_deferrable", 1}
MC/DC0%0/1
$rels{$fk}{"attrs"} ||= {"on_delete", $rules{$delete_rule}, "on_update", $rules{$update_rule}, "is_deferrable", 1}
$rels{$fk}{"attrs"}
Truth table0%0/2
A
A= $rels{$fk}{"attrs"}
| |||||||||||||||||||||||||||||||||||||||||||
| 149 | is_deferrable => 1, # DB2 has no deferrable constraints | ||||||||||||||||||||||||||||||||||||||||||
| 150 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 151 | } | ||||||||||||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | return [ values %rels ]; | |||||||||||||||||||||||||||||||||||||||||
| 154 | } | ||||||||||||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||||||||||||
| 157 | # DBD::DB2 doesn't follow the DBI API for ->tables (pre 1.85), but since its | ||||||||||||||||||||||||||||||||||||||||||
| 158 | # backwards compatible we don't change it. | ||||||||||||||||||||||||||||||||||||||||||
| 159 | # DBD::DB2 1.85 and beyond default TABLE_NAME to '', previously defaulted to | ||||||||||||||||||||||||||||||||||||||||||
| 160 | # '%'. so we supply it. | ||||||||||||||||||||||||||||||||||||||||||
| 161 | 0 | ▶ | sub _dbh_tables { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_dbh_tables: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 162 | 0 | my ($self, $schema) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||||||||||||
| 164 | 0 | ▶ | return $self->dbh->tables($schema ? { TABLE_SCHEM => $schema, TABLE_NAME => '%' } : undef); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 165 | } | ||||||||||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||||||||||
| 167 | 0 | ▶ | sub _dbh_table_info { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_dbh_table_info: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 168 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||||||||||||
| 170 | 0 | local $^W = 0; # shut up undef warning from DBD::DB2 | |||||||||||||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||||||||||||||
| 172 | 0 | $self->next::method(@_); | |||||||||||||||||||||||||||||||||||||||||
| 173 | } | ||||||||||||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||||||||||||
| 175 | 0 | ▶ | sub _columns_info_for { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_columns_info_for: not called CC=17 SCAR=56.1
| |||||||||||||||||||||||||||||||||||||||||||
| 176 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 177 | 0 | my ($table) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||||||||||||||||
| 179 | 0 | my $result = $self->next::method(@_); | |||||||||||||||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||||||||||||||||
| 181 | 0 | ▶ | while (my ($col, $info) = each %$result) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 182 | # check for identities | ||||||||||||||||||||||||||||||||||||||||||
| 183 | 0 | my $sth = $self->dbh->prepare_cached( | |||||||||||||||||||||||||||||||||||||||||
| 184 | q{ | ||||||||||||||||||||||||||||||||||||||||||
| 185 | SELECT COUNT(*) | ||||||||||||||||||||||||||||||||||||||||||
| 186 | FROM syscat.columns | ||||||||||||||||||||||||||||||||||||||||||
| 187 | WHERE tabschema = ? AND tabname = ? AND colname = ? | ||||||||||||||||||||||||||||||||||||||||||
| 188 | AND identity = 'Y' AND generated != '' | ||||||||||||||||||||||||||||||||||||||||||
| 189 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 190 | {}, 1); | ||||||||||||||||||||||||||||||||||||||||||
| 191 | 0 | $sth->execute($table->schema, $table->name, $self->_uc($col)); | |||||||||||||||||||||||||||||||||||||||||
| 192 | 0 | ▶ | if ($sth->fetchrow_array) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 193 | 0 | $info->{is_auto_increment} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 194 | } | ||||||||||||||||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||||||||||||||||
| 196 | 0 | my $data_type = $info->{data_type}; | |||||||||||||||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||||||||||||||||
| 198 | 0 | ▶ | if ($data_type !~ /^(?:(?:var)?(?:char|graphic)|decimal)\z/i) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 199 | 0 | delete $info->{size}; | |||||||||||||||||||||||||||||||||||||||||
| 200 | } | ||||||||||||||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||||||||||||
| 202 | 0 | ▶ | if ($data_type eq 'double') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 203 | 0 | $info->{data_type} = 'double precision'; | |||||||||||||||||||||||||||||||||||||||||
| 204 | } | ||||||||||||||||||||||||||||||||||||||||||
| 205 | elsif ($data_type eq 'decimal') { | ||||||||||||||||||||||||||||||||||||||||||
| 206 | 1 | ▶ | no warnings 'uninitialized'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||||||||||||||||
| 208 | 0 | $info->{data_type} = 'numeric'; | |||||||||||||||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||||||||||||||||
| 210 | 0 | ▶ | my @size = @{ $info->{size} || [] }; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$info->{'size'} || []
MC/DC0%0/1
$info->{'size'} || []
$info->{'size'}
Truth table0%0/2
A
A= $info->{'size'}
| |||||||||||||||||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||||||||||||||||
| 212 | 0 | ▶ | if ($size[0] == 5 && $size[1] == 0) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$size[0] == 5 and $size[1] == 0
MC/DC0%0/2
$size[0] == 5 and $size[1] == 0
$size[0] == 5
$size[1] == 0
Truth table0%0/3
A and B
A= $size[0] == 5B= $size[1] == 0
| |||||||||||||||||||||||||||||||||||||||||||
| 213 | 0 | delete $info->{size}; | |||||||||||||||||||||||||||||||||||||||||
| 214 | } | ||||||||||||||||||||||||||||||||||||||||||
| 215 | } | ||||||||||||||||||||||||||||||||||||||||||
| 216 | elsif ($data_type =~ /^(?:((?:var)?char) \(\) for bit data|(long varchar) for bit data)\z/i) { | ||||||||||||||||||||||||||||||||||||||||||
| 217 | 0 | ▶ | my $base_type = lc($1 || $2); | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$1 || $2
MC/DC0%0/2
$1 || $2
$1
$2
Truth table0%0/3
A || B
A= $1B= $2
| |||||||||||||||||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||||||||||||||||
| 219 | 0 | (my $original_type = $data_type) =~ s/[()]+ //; | |||||||||||||||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||||||||||||||||
| 221 | 0 | $info->{original}{data_type} = $original_type; | |||||||||||||||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||||||||||||||||
| 223 | 0 | ▶ | if ($base_type eq 'long varchar') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 224 | 0 | $info->{data_type} = 'blob'; | |||||||||||||||||||||||||||||||||||||||||
| 225 | } | ||||||||||||||||||||||||||||||||||||||||||
| 226 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 227 | 0 | ▶ | if ($base_type eq 'char') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 228 | 0 | $info->{data_type} = 'binary'; | |||||||||||||||||||||||||||||||||||||||||
| 229 | } | ||||||||||||||||||||||||||||||||||||||||||
| 230 | elsif ($base_type eq 'varchar') { | ||||||||||||||||||||||||||||||||||||||||||
| 231 | 0 | $info->{data_type} = 'varbinary'; | |||||||||||||||||||||||||||||||||||||||||
| 232 | } | ||||||||||||||||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||||||||||||||||
| 234 | 0 | my ($size) = $self->dbh->selectrow_array(<<'EOF', {}, $table->schema, $table->name, $self->_uc($col)); | |||||||||||||||||||||||||||||||||||||||||
| 235 | SELECT length | ||||||||||||||||||||||||||||||||||||||||||
| 236 | FROM syscat.columns | ||||||||||||||||||||||||||||||||||||||||||
| 237 | WHERE tabschema = ? AND tabname = ? AND colname = ? | ||||||||||||||||||||||||||||||||||||||||||
| 238 | EOF | ||||||||||||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||||||||||||
| 240 | 0 | ▶ | $info->{size} = $size if $size; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 241 | } | ||||||||||||||||||||||||||||||||||||||||||
| 242 | } | ||||||||||||||||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||||||||||||||||
| 244 | 0 | ▶ | if ((eval { lc ${ $info->{default_value} } }||'') =~ /^current (date|time(?:stamp)?)\z/i) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
eval {
do {
lc ${$info->{'default_value'};}
}
} || ''
MC/DC0%0/1
eval {
do {
lc ${$info->{'default_value'};}
}
} || ''
eval {
do {
lc ${$info->{'default_value'};}
}
}
Truth table0%0/2
A
A= eval {
do {
lc ${$info->{'default_value'};}
}
}
| |||||||||||||||||||||||||||||||||||||||||||
| 245 | 0 | my $type = lc($1); | |||||||||||||||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||||||||||||||||
| 247 | 0 | ${ $info->{default_value} } = 'current_timestamp'; | |||||||||||||||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||||||||||||||||
| 249 | 0 | my $orig_deflt = "current $type"; | |||||||||||||||||||||||||||||||||||||||||
| 250 | 0 | $info->{original}{default_value} = \$orig_deflt; | |||||||||||||||||||||||||||||||||||||||||
| 251 | } | ||||||||||||||||||||||||||||||||||||||||||
| 252 | } | ||||||||||||||||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||||||||||||||||
| 254 | 0 | return $result; | |||||||||||||||||||||||||||||||||||||||||
| 255 | } | ||||||||||||||||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||||||||||||||||
| 257 | =head1 SEE ALSO | ||||||||||||||||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||||||||||||||||
| 259 | L<DBIx::Class::Schema::Loader>, L<DBIx::Class::Schema::Loader::Base>, | ||||||||||||||||||||||||||||||||||||||||||
| 260 | L<DBIx::Class::Schema::Loader::DBI> | ||||||||||||||||||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||||||||||||||||
| 262 | =head1 AUTHORS | ||||||||||||||||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||||||||||||||||
| 264 | See L<DBIx::Class::Schema::Loader/AUTHORS>. | ||||||||||||||||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||||||||||||||||
| 266 | =head1 LICENSE | ||||||||||||||||||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||||||||||||||||
| 268 | This library is free software; you can redistribute it and/or modify it under | ||||||||||||||||||||||||||||||||||||||||||
| 269 | the same terms as Perl itself. | ||||||||||||||||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||||||||||||||||
| 271 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||||||||||||||||
| 273 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 274 | # vim:et sts=4 sw=4 tw=0: | ||||||||||||||||||||||||||||||||||||||||||