| 1 | package DBIx::Class::Storage::DBI::SQLite; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | 217 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 217 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||
| 6 | 217 | ▶ | use base qw/DBIx::Class::Storage::DBI/; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | 217 | ▶ | use mro 'c3'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||
| 9 | 217 | ▶ | use SQL::Abstract::Util 'is_plain_value'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | 217 | ▶ | use DBIx::Class::_Util qw(modver_gt_or_eq sigwarn_silencer); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | 217 | ▶ | use DBIx::Class::Carp; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 12 | 217 | ▶ | use Try::Tiny; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 13 | 217 | ▶ | use namespace::clean; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||
| 15 | 217 | __PACKAGE__->sql_maker_class('DBIx::Class::SQLMaker::SQLite'); | |||||||||||||||||||||||||||||||||||||||||
| 16 | 217 | __PACKAGE__->sql_limit_dialect ('LimitOffset'); | |||||||||||||||||||||||||||||||||||||||||
| 17 | 217 | __PACKAGE__->sql_quote_char ('"'); | |||||||||||||||||||||||||||||||||||||||||
| 18 | 217 | __PACKAGE__->datetime_parser_type ('DateTime::Format::SQLite'); | |||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||
| 20 | 3 | ▶ | sub _determine_supports_multicolumn_in { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_determine_supports_multicolumn_in: called CC=2 SCAR=7.6
| |||||||||||||||||||||||||||||||||||||||||||
| 21 | 3 | ▶ | ( shift->_server_info->{normalized_dbms_version} < '3.014' ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 22 | ? 0 | ||||||||||||||||||||||||||||||||||||||||||
| 23 | : 1 | ||||||||||||||||||||||||||||||||||||||||||
| 24 | } | ||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||
| 27 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||
| 29 | DBIx::Class::Storage::DBI::SQLite - Automatic primary key class for SQLite | ||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||
| 31 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||
| 33 | # In your table classes | ||||||||||||||||||||||||||||||||||||||||||
| 34 | use base 'DBIx::Class::Core'; | ||||||||||||||||||||||||||||||||||||||||||
| 35 | __PACKAGE__->set_primary_key('id'); | ||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||
| 37 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||
| 39 | This class implements autoincrements for SQLite. | ||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||
| 41 | =head2 Known Issues | ||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||
| 43 | =over | ||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||
| 45 | =item RT79576 | ||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||
| 47 | NOTE - This section applies to you only if ALL of these are true: | ||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||
| 49 | * You are or were using DBD::SQLite with a version lesser than 1.38_01 | ||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||
| 51 | * You are or were using DBIx::Class versions between 0.08191 and 0.08209 | ||||||||||||||||||||||||||||||||||||||||||
| 52 | (inclusive) or between 0.08240-TRIAL and 0.08242-TRIAL (also inclusive) | ||||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||
| 54 | * You use objects with overloaded stringification and are feeding them | ||||||||||||||||||||||||||||||||||||||||||
| 55 | to DBIC CRUD methods directly | ||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||
| 57 | An unfortunate chain of events led to DBIx::Class silently hitting the problem | ||||||||||||||||||||||||||||||||||||||||||
| 58 | described in L<RT#79576|https://rt.cpan.org/Public/Bug/Display.html?id=79576>. | ||||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||
| 60 | In order to trigger the bug condition one needs to supply B<more than one> | ||||||||||||||||||||||||||||||||||||||||||
| 61 | bind value that is an object with overloaded stringification (numification | ||||||||||||||||||||||||||||||||||||||||||
| 62 | is not relevant, only stringification is). When this is the case the internal | ||||||||||||||||||||||||||||||||||||||||||
| 63 | DBIx::Class call to C<< $sth->bind_param >> would be executed in a way that | ||||||||||||||||||||||||||||||||||||||||||
| 64 | triggers the above-mentioned DBD::SQLite bug. As a result all the logs and | ||||||||||||||||||||||||||||||||||||||||||
| 65 | tracers will contain the expected values, however SQLite will receive B<all> | ||||||||||||||||||||||||||||||||||||||||||
| 66 | these bind positions being set to the value of the B<last> supplied | ||||||||||||||||||||||||||||||||||||||||||
| 67 | stringifiable object. | ||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||
| 69 | Even if you upgrade DBIx::Class (which works around the bug starting from | ||||||||||||||||||||||||||||||||||||||||||
| 70 | version 0.08210) you may still have corrupted/incorrect data in your database. | ||||||||||||||||||||||||||||||||||||||||||
| 71 | DBIx::Class warned about this condition for several years, hoping to give | ||||||||||||||||||||||||||||||||||||||||||
| 72 | anyone affected sufficient notice of the potential issues. The warning was | ||||||||||||||||||||||||||||||||||||||||||
| 73 | removed in 2015/v0.082820. | ||||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||
| 75 | =back | ||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||
| 77 | =head1 METHODS | ||||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||
| 79 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||
| 81 | 0 | ▶ | sub backup { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
backup: not called CC=10 SCAR=47.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||
| 83 | 0 | require File::Spec; | |||||||||||||||||||||||||||||||||||||||||
| 84 | 0 | require File::Copy; | |||||||||||||||||||||||||||||||||||||||||
| 85 | 0 | require POSIX; | |||||||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | my ($self, $dir) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 88 | 0 | ▶ | $dir ||= './'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$dir ||= "./"
MC/DC0%0/1
$dir ||= "./"
$dir
Truth table0%0/2
A
A= $dir
| |||||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||
| 90 | ## Where is the db file? | ||||||||||||||||||||||||||||||||||||||||||
| 91 | 0 | my $dsn = $self->_dbi_connect_info()->[0]; | |||||||||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||||||||||
| 93 | 0 | ▶ | my $dbname = $1 if($dsn =~ /dbname=([^;]+)/); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 94 | 0 | ▶ | if(!$dbname) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 95 | { | ||||||||||||||||||||||||||||||||||||||||||
| 96 | 0 | ▶ | $dbname = $1 if($dsn =~ /^dbi:SQLite:(.+)$/i); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 97 | } | ||||||||||||||||||||||||||||||||||||||||||
| 98 | 0 | ▶ | $self->throw_exception("Cannot determine name of SQLite db file") | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$dbname and -f $dbname
MC/DC0%0/2
$dbname and -f $dbname
$dbname
-f $dbname
Truth table0%0/3
A and B
A= $dbnameB= -f $dbname
| |||||||||||||||||||||||||||||||||||||||||||
| 99 | if(!$dbname || !-f $dbname); | ||||||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||||||
| 101 | # print "Found database: $dbname\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 102 | # my $dbfile = file($dbname); | ||||||||||||||||||||||||||||||||||||||||||
| 103 | 0 | my ($vol, $dbdir, $file) = File::Spec->splitpath($dbname); | |||||||||||||||||||||||||||||||||||||||||
| 104 | # my $file = $dbfile->basename(); | ||||||||||||||||||||||||||||||||||||||||||
| 105 | 0 | $file = POSIX::strftime("%Y-%m-%d-%H_%M_%S", localtime()) . $file; | |||||||||||||||||||||||||||||||||||||||||
| 106 | 0 | ▶ | $file = "B$file" while(-f $file); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||||||||||
| 108 | 0 | ▶ | mkdir($dir) unless -f $dir; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 109 | 0 | my $backupfile = File::Spec->catfile($dir, $file); | |||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | my $res = File::Copy::copy($dbname, $backupfile); | |||||||||||||||||||||||||||||||||||||||||
| 112 | 0 | ▶ | $self->throw_exception("Backup failed! ($!)") if(!$res); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||||
| 114 | 0 | return $backupfile; | |||||||||||||||||||||||||||||||||||||||||
| 115 | } | ||||||||||||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||||||||||||
| 117 | 21 | ▶ | sub _exec_svp_begin { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_exec_svp_begin: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 118 | 21 | my ($self, $name) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||||||||||
| 120 | 21 | $self->_dbh->do("SAVEPOINT $name"); | |||||||||||||||||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||||||||||
| 123 | 9 | ▶ | sub _exec_svp_release { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_exec_svp_release: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 124 | 9 | my ($self, $name) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||||||||||||||
| 126 | 9 | $self->_dbh->do("RELEASE SAVEPOINT $name"); | |||||||||||||||||||||||||||||||||||||||||
| 127 | } | ||||||||||||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||||||||||||
| 129 | 14 | ▶ | sub _exec_svp_rollback { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_exec_svp_rollback: called CC=3 SCAR=14.2
| |||||||||||||||||||||||||||||||||||||||||||
| 130 | 14 | my ($self, $name) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||||||||||||
| 132 | 14 | $self->_dbh->do("ROLLBACK TO SAVEPOINT $name"); | |||||||||||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||||||||||||
| 134 | # resync state for older DBD::SQLite (RT#67843) | ||||||||||||||||||||||||||||||||||||||||||
| 135 | # https://github.com/DBD-SQLite/DBD-SQLite/commit/9b3cdbf | ||||||||||||||||||||||||||||||||||||||||||
| 136 | 14 | ▶ | if ( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not &modver_gt_or_eq("DBD::SQLite", "1.33") and $self->_dbh->FETCH("AutoCommit")
MC/DC0%0/2
not &modver_gt_or_eq("DBD::SQLite", "1.33") and $self->_dbh->FETCH("AutoCommit")
not &modver_gt_or_eq("DBD::SQLite", "1.33")
$self->_dbh->FETCH("AutoCommit")
Truth table33%1/3
not(A) and B
A= not &modver_gt_or_eq("DBD::SQLite", "1.33")B= $self->_dbh->FETCH("AutoCommit")
| |||||||||||||||||||||||||||||||||||||||||||
| 137 | ! modver_gt_or_eq('DBD::SQLite', '1.33') | ||||||||||||||||||||||||||||||||||||||||||
| 138 | and | ||||||||||||||||||||||||||||||||||||||||||
| 139 | $self->_dbh->FETCH('AutoCommit') | ||||||||||||||||||||||||||||||||||||||||||
| 140 | ) { | ||||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | $self->_dbh->STORE('AutoCommit', 0); | |||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | $self->_dbh->STORE('BegunWork', 1); | |||||||||||||||||||||||||||||||||||||||||
| 143 | } | ||||||||||||||||||||||||||||||||||||||||||
| 144 | } | ||||||||||||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||||||||||||
| 146 | 145 | ▶ | sub _ping { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_ping: called CC=15 SCAR=44.2
| |||||||||||||||||||||||||||||||||||||||||||
| 147 | 145 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||||||||||||||||
| 149 | # Be extremely careful what we do here. SQLite is notoriously bad at | ||||||||||||||||||||||||||||||||||||||||||
| 150 | # synchronizing its internal transaction state with {AutoCommit} | ||||||||||||||||||||||||||||||||||||||||||
| 151 | # https://metacpan.org/source/ADAMK/DBD-SQLite-1.37/lib/DBD/SQLite.pm#L921 | ||||||||||||||||||||||||||||||||||||||||||
| 152 | # There is a function http://www.sqlite.org/c3ref/get_autocommit.html | ||||||||||||||||||||||||||||||||||||||||||
| 153 | # but DBD::SQLite does not expose it (nor does it seem to properly use it) | ||||||||||||||||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||||||||||||||||
| 155 | # Therefore only execute a "ping" when we have no other choice *AND* | ||||||||||||||||||||||||||||||||||||||||||
| 156 | # scrutinize the thrown exceptions to make sure we are where we think we are | ||||||||||||||||||||||||||||||||||||||||||
| 157 | 145 | ▶ | my $dbh = $self->_dbh or return undef; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 158 | 145 | ▶ | return undef unless $dbh->FETCH('Active'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 159 | 145 | ▶ | return undef unless $dbh->ping; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||||||||||
| 161 | 145 | my $ping_fail; | |||||||||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||||||||||
| 163 | # older DBD::SQLite does not properly synchronize commit state between | ||||||||||||||||||||||||||||||||||||||||||
| 164 | # the libsqlite and the $dbh | ||||||||||||||||||||||||||||||||||||||||||
| 165 | 145 | ▶ | unless (defined $DBD::SQLite::__DBIC_TXN_SYNC_SANE__) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 166 | 28 | $DBD::SQLite::__DBIC_TXN_SYNC_SANE__ = modver_gt_or_eq('DBD::SQLite', '1.38_02'); | |||||||||||||||||||||||||||||||||||||||||
| 167 | } | ||||||||||||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||||||||||||
| 169 | # fallback to travesty | ||||||||||||||||||||||||||||||||||||||||||
| 170 | 145 | ▶ | unless ($DBD::SQLite::__DBIC_TXN_SYNC_SANE__) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 171 | # since we do not have access to sqlite3_get_autocommit(), do a trick | ||||||||||||||||||||||||||||||||||||||||||
| 172 | # to attempt to *safely* determine what state are we *actually* in. | ||||||||||||||||||||||||||||||||||||||||||
| 173 | # FIXME | ||||||||||||||||||||||||||||||||||||||||||
| 174 | # also using T::T here leads to bizarre leaks - will figure it out later | ||||||||||||||||||||||||||||||||||||||||||
| 175 | 0 | my $really_not_in_txn = do { | |||||||||||||||||||||||||||||||||||||||||
| 176 | 0 | local $@; | |||||||||||||||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||||||||||||||||
| 178 | # older versions of DBD::SQLite do not properly detect multiline BEGIN/COMMIT | ||||||||||||||||||||||||||||||||||||||||||
| 179 | # statements to adjust their {AutoCommit} state. Hence use such a statement | ||||||||||||||||||||||||||||||||||||||||||
| 180 | # pair here as well, in order to escape from poking {AutoCommit} needlessly | ||||||||||||||||||||||||||||||||||||||||||
| 181 | # https://rt.cpan.org/Public/Bug/Display.html?id=80087 | ||||||||||||||||||||||||||||||||||||||||||
| 182 | eval { | ||||||||||||||||||||||||||||||||||||||||||
| 183 | # will fail instantly if already in a txn | ||||||||||||||||||||||||||||||||||||||||||
| 184 | 0 | $dbh->do("-- multiline\nBEGIN"); | |||||||||||||||||||||||||||||||||||||||||
| 185 | 0 | $dbh->do("-- multiline\nCOMMIT"); | |||||||||||||||||||||||||||||||||||||||||
| 186 | 0 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 187 | 0 | ▶ | } or do { | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
eval {
do {
$dbh->do("-- multiline\nBEGIN");
$dbh->do("-- multiline\nCOMMIT");
1
}
} || do {
$@ =~ /transaction within a transaction/ ? 0 : undef
}
MC/DC0%0/2
eval {
do {
$dbh->do("-- multiline\nBEGIN");
$dbh->do("-- multiline\nCOMMIT");
1
}
} || do {
$@ =~ /transaction within a transaction/ ? 0 : undef
}
eval {
do {
$dbh->do("-- multiline\nBEGIN");
$dbh->do("-- multiline\nCOMMIT");
1
}
}
do {
$@ =~ /transaction within a transaction/ ? 0 : undef
}
Truth table0%0/3
A || B
A= eval {
do {
$dbh->do("-- multiline\nBEGIN");
$dbh->do("-- multiline\nCOMMIT");
1
}
}B= do {
$@ =~ /transaction within a transaction/ ? 0 : undef
}
| |||||||||||||||||||||||||||||||||||||||||||
| 188 | 0 | ▶ | ($@ =~ /transaction within a transaction/) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 189 | ? 0 | ||||||||||||||||||||||||||||||||||||||||||
| 190 | : undef | ||||||||||||||||||||||||||||||||||||||||||
| 191 | ; | ||||||||||||||||||||||||||||||||||||||||||
| 192 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 193 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||||||||||||||||
| 195 | # if we were unable to determine this - we may very well be dead | ||||||||||||||||||||||||||||||||||||||||||
| 196 | 0 | ▶ | if (not defined $really_not_in_txn) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 197 | 0 | $ping_fail = 1; | |||||||||||||||||||||||||||||||||||||||||
| 198 | } | ||||||||||||||||||||||||||||||||||||||||||
| 199 | # check the AC sync-state | ||||||||||||||||||||||||||||||||||||||||||
| 200 | ▶ | elsif ($really_not_in_txn xor $dbh->{AutoCommit}) { | |||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/4
$really_not_in_txn xor $dbh->{"AutoCommit"}
MC/DC0%0/2
$really_not_in_txn xor $dbh->{"AutoCommit"}
$really_not_in_txn
$dbh->{"AutoCommit"}
Truth table0%0/4
A xor B
A= $really_not_in_txnB= $dbh->{"AutoCommit"}
| |||||||||||||||||||||||||||||||||||||||||||
| 201 | carp_unique (sprintf | ||||||||||||||||||||||||||||||||||||||||||
| 202 | 'Internal transaction state of handle %s (apparently %s a transaction) does not seem to ' | ||||||||||||||||||||||||||||||||||||||||||
| 203 | . 'match its AutoCommit attribute setting of %s - this is an indication of a ' | ||||||||||||||||||||||||||||||||||||||||||
| 204 | . 'potentially serious bug in your transaction handling logic', | ||||||||||||||||||||||||||||||||||||||||||
| 205 | $dbh, | ||||||||||||||||||||||||||||||||||||||||||
| 206 | $really_not_in_txn ? 'NOT in' : 'in', | ||||||||||||||||||||||||||||||||||||||||||
| 207 | 0 | ▶ | $dbh->{AutoCommit} ? 'TRUE' : 'FALSE', | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 208 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||||||||||||||||
| 210 | # it is too dangerous to execute anything else in this state | ||||||||||||||||||||||||||||||||||||||||||
| 211 | # assume everything works (safer - worst case scenario next statement throws) | ||||||||||||||||||||||||||||||||||||||||||
| 212 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 213 | } | ||||||||||||||||||||||||||||||||||||||||||
| 214 | } | ||||||||||||||||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||||||||||||||||
| 216 | # do the actual test and return on no failure | ||||||||||||||||||||||||||||||||||||||||||
| 217 | 145 | ▶ | ( $ping_fail ||= ! try { $dbh->do('SELECT * FROM sqlite_master LIMIT 1'); 1 } ) | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 218 | 145 | ▶ | or return 1; # the actual RV of _ping() | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$ping_fail ||= !&try(sub {
$dbh->do("SELECT * FROM sqlite_master LIMIT 1");
1;
}
)
MC/DC0%0/2
$ping_fail ||= !&try(sub {
$dbh->do("SELECT * FROM sqlite_master LIMIT 1");
1;
}
)
$ping_fail
!&try(sub {
$dbh->do("SELECT * FROM sqlite_master LIMIT 1");
1;
}
)
Truth table33%1/3
A ||= not(B)
A= $ping_failB= !&try(sub {
$dbh->do("SELECT * FROM sqlite_master LIMIT 1");
1;
}
)
| |||||||||||||||||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||||||||||||||||
| 220 | # ping failed (or so it seems) - need to do some cleanup | ||||||||||||||||||||||||||||||||||||||||||
| 221 | # it is possible to have a proper "connection", and have "ping" return | ||||||||||||||||||||||||||||||||||||||||||
| 222 | # false anyway (e.g. corrupted file). In such cases DBD::SQLite still | ||||||||||||||||||||||||||||||||||||||||||
| 223 | # keeps the actual file handle open. We don't really want this to happen, | ||||||||||||||||||||||||||||||||||||||||||
| 224 | # so force-close the handle via DBI itself | ||||||||||||||||||||||||||||||||||||||||||
| 225 | # | ||||||||||||||||||||||||||||||||||||||||||
| 226 | 0 | local $@; # so that we do not clobber the real error as set above | |||||||||||||||||||||||||||||||||||||||||
| 227 | 0 | eval { $dbh->disconnect }; # if it fails - it fails | |||||||||||||||||||||||||||||||||||||||||
| 228 | 0 | undef; # the actual RV of _ping() | |||||||||||||||||||||||||||||||||||||||||
| 229 | } | ||||||||||||||||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||||||||||||||||
| 231 | 1 | ▶ | sub deployment_statements { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
deployment_statements: called CC=4 SCAR=15.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 232 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 233 | 1 | my ($schema, $type, $version, $dir, $sqltargs, @rest) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||||||||||||||||
| 235 | 1 | ▶ | $sqltargs ||= {}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$sqltargs ||= {}
MC/DC0%0/1
$sqltargs ||= {}
$sqltargs
Truth table50%1/2
A
A= $sqltargs
| |||||||||||||||||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||||||||||||||||
| 237 | 1 | ▶ | if ( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not exists $sqltargs->{"producer_args"}{"sqlite_version"} and my $dver = $self->_server_info->{"normalized_dbms_version"}
MC/DC0%0/2
not exists $sqltargs->{"producer_args"}{"sqlite_version"} and my $dver = $self->_server_info->{"normalized_dbms_version"}
not exists $sqltargs->{"producer_args"}{"sqlite_version"}
my $dver = $self->_server_info->{"normalized_dbms_version"}
Truth table33%1/3
not(A) and B
A= not exists $sqltargs->{"producer_args"}{"sqlite_version"}B= my $dver = $self->_server_info->{"normalized_dbms_version"}
| |||||||||||||||||||||||||||||||||||||||||||
| 238 | ! exists $sqltargs->{producer_args}{sqlite_version} | ||||||||||||||||||||||||||||||||||||||||||
| 239 | and | ||||||||||||||||||||||||||||||||||||||||||
| 240 | my $dver = $self->_server_info->{normalized_dbms_version} | ||||||||||||||||||||||||||||||||||||||||||
| 241 | ) { | ||||||||||||||||||||||||||||||||||||||||||
| 242 | 1 | $sqltargs->{producer_args}{sqlite_version} = $dver; | |||||||||||||||||||||||||||||||||||||||||
| 243 | } | ||||||||||||||||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||||||||||||||||
| 245 | 1 | $self->next::method($schema, $type, $version, $dir, $sqltargs, @rest); | |||||||||||||||||||||||||||||||||||||||||
| 246 | } | ||||||||||||||||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||||||||||||||||
| 248 | 2373 | ▶ | sub bind_attribute_by_data_type { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
bind_attribute_by_data_type: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||||||||||||||||
| 250 | # According to http://www.sqlite.org/datatype3.html#storageclasses | ||||||||||||||||||||||||||||||||||||||||||
| 251 | # all numeric types are dynamically allocated up to 8 bytes per | ||||||||||||||||||||||||||||||||||||||||||
| 252 | # individual value | ||||||||||||||||||||||||||||||||||||||||||
| 253 | # Thus it should be safe and non-wasteful to bind everything as | ||||||||||||||||||||||||||||||||||||||||||
| 254 | # SQL_BIGINT and have SQLite deal with storage/comparisons however | ||||||||||||||||||||||||||||||||||||||||||
| 255 | # it deems correct | ||||||||||||||||||||||||||||||||||||||||||
| 256 | 2373 | ▶ | $_[1] =~ /^ (?: int(?:[1248]|eger)? | (?:tiny|small|medium|big)int ) $/ix | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 257 | ? DBI::SQL_BIGINT() | ||||||||||||||||||||||||||||||||||||||||||
| 258 | : undef | ||||||||||||||||||||||||||||||||||||||||||
| 259 | ; | ||||||||||||||||||||||||||||||||||||||||||
| 260 | } | ||||||||||||||||||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||||||||||||||||
| 262 | # FIXME - what the flying fuck... work around RT#76395 | ||||||||||||||||||||||||||||||||||||||||||
| 263 | # DBD::SQLite warns on binding >32 bit values with 32 bit IVs | ||||||||||||||||||||||||||||||||||||||||||
| 264 | 10074 | ▶ | sub _dbh_execute { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_dbh_execute: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 265 | 10074 | if ( | |||||||||||||||||||||||||||||||||||||||||
| 266 | ( | ||||||||||||||||||||||||||||||||||||||||||
| 267 | DBIx::Class::_ENV_::IV_SIZE < 8 | ||||||||||||||||||||||||||||||||||||||||||
| 268 | or | ||||||||||||||||||||||||||||||||||||||||||
| 269 | DBIx::Class::_ENV_::OS_NAME eq 'MSWin32' | ||||||||||||||||||||||||||||||||||||||||||
| 270 | ) | ||||||||||||||||||||||||||||||||||||||||||
| 271 | and | ||||||||||||||||||||||||||||||||||||||||||
| 272 | ! defined $DBD::SQLite::__DBIC_CHECK_dbd_mishandles_bound_BIGINT | ||||||||||||||||||||||||||||||||||||||||||
| 273 | ) { | ||||||||||||||||||||||||||||||||||||||||||
| 274 | $DBD::SQLite::__DBIC_CHECK_dbd_mishandles_bound_BIGINT = ( | ||||||||||||||||||||||||||||||||||||||||||
| 275 | modver_gt_or_eq('DBD::SQLite', '1.37') | ||||||||||||||||||||||||||||||||||||||||||
| 276 | ) ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||
| 277 | } | ||||||||||||||||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||||||||||||||||
| 279 | 10074 | local $SIG{__WARN__} = sigwarn_silencer( qr/ | |||||||||||||||||||||||||||||||||||||||||
| 280 | \Qdatatype mismatch: bind\E \s (?: | ||||||||||||||||||||||||||||||||||||||||||
| 281 | param \s+ \( \d+ \) \s+ [-+]? \d+ (?: \. 0*)? \Q as integer\E | ||||||||||||||||||||||||||||||||||||||||||
| 282 | | | ||||||||||||||||||||||||||||||||||||||||||
| 283 | \d+ \s type \s @{[ DBI::SQL_BIGINT() ]} \s as \s [-+]? \d+ (?: \. 0*)? | ||||||||||||||||||||||||||||||||||||||||||
| 284 | ) | ||||||||||||||||||||||||||||||||||||||||||
| 285 | /x ) if ( | ||||||||||||||||||||||||||||||||||||||||||
| 286 | ( | ||||||||||||||||||||||||||||||||||||||||||
| 287 | DBIx::Class::_ENV_::IV_SIZE < 8 | ||||||||||||||||||||||||||||||||||||||||||
| 288 | or | ||||||||||||||||||||||||||||||||||||||||||
| 289 | DBIx::Class::_ENV_::OS_NAME eq 'MSWin32' | ||||||||||||||||||||||||||||||||||||||||||
| 290 | ) | ||||||||||||||||||||||||||||||||||||||||||
| 291 | and | ||||||||||||||||||||||||||||||||||||||||||
| 292 | $DBD::SQLite::__DBIC_CHECK_dbd_mishandles_bound_BIGINT | ||||||||||||||||||||||||||||||||||||||||||
| 293 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||||||||||||||||
| 295 | 10074 | shift->next::method(@_); | |||||||||||||||||||||||||||||||||||||||||
| 296 | } | ||||||||||||||||||||||||||||||||||||||||||
| 297 | |||||||||||||||||||||||||||||||||||||||||||
| 298 | # DBD::SQLite (at least up to version 1.31 has a bug where it will | ||||||||||||||||||||||||||||||||||||||||||
| 299 | # non-fatally numify a string value bound as an integer, resulting | ||||||||||||||||||||||||||||||||||||||||||
| 300 | # in insertions of '0' into supposed-to-be-numeric fields | ||||||||||||||||||||||||||||||||||||||||||
| 301 | # Since this can result in severe data inconsistency, remove the | ||||||||||||||||||||||||||||||||||||||||||
| 302 | # bind attr if such a situation is detected | ||||||||||||||||||||||||||||||||||||||||||
| 303 | # | ||||||||||||||||||||||||||||||||||||||||||
| 304 | # FIXME - when a DBD::SQLite version is released that eventually fixes | ||||||||||||||||||||||||||||||||||||||||||
| 305 | # this situation (somehow) - no-op this override once a proper DBD | ||||||||||||||||||||||||||||||||||||||||||
| 306 | # version is detected | ||||||||||||||||||||||||||||||||||||||||||
| 307 | 17693 | ▶ | sub _dbi_attrs_for_bind { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_dbi_attrs_for_bind: called CC=13 SCAR=30.9
| |||||||||||||||||||||||||||||||||||||||||||
| 308 | 17693 | my ($self, $ident, $bind) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||||||||||||||||
| 310 | 17693 | my $bindattrs = $self->next::method($ident, $bind); | |||||||||||||||||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||||||||||||||||
| 312 | 17693 | ▶ | if (! defined $DBD::SQLite::__DBIC_CHECK_dbd_can_bind_bigint_values) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 313 | 201 | ▶ | $DBD::SQLite::__DBIC_CHECK_dbd_can_bind_bigint_values | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 314 | = modver_gt_or_eq('DBD::SQLite', '1.37') ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||
| 315 | } | ||||||||||||||||||||||||||||||||||||||||||
| 316 | |||||||||||||||||||||||||||||||||||||||||||
| 317 | 17693 | for my $i (0.. $#$bindattrs) { | |||||||||||||||||||||||||||||||||||||||||
| 318 | 41936 | ▶ | if ( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
defined $bindattrs->[$i] and defined $bind->[$i][1] and grep {$bindattrs->[$i] eq $_;} &DBI::SQL_INTEGER(), &DBI::SQL_TINYINT(), &DBI::SQL_SMALLINT(), &DBI::SQL_BIGINT()
defined $bindattrs->[$i] and defined $bind->[$i][1]
MC/DC66%2/3
defined $bindattrs->[$i] and defined $bind->[$i][1] and grep {$bindattrs->[$i] eq $_;} &DBI::SQL_INTEGER(), &DBI::SQL_TINYINT(), &DBI::SQL_SMALLINT(), &DBI::SQL_BIGINT()
defined $bindattrs->[$i]
defined $bind->[$i][1]
grep {$bindattrs->[$i] eq $_;} &DBI::SQL_INTEGER(), &DBI::SQL_TINYINT(), &DBI::SQL_SMALLINT(), &DBI::SQL_BIGINT()
Truth table75%3/4
A and B and C
A= defined $bindattrs->[$i]B= defined $bind->[$i][1]C= grep {$bindattrs->[$i] eq $_;} &DBI::SQL_INTEGER(), &DBI::SQL_TINYINT(), &DBI::SQL_SMALLINT(), &DBI::SQL_BIGINT()
| |||||||||||||||||||||||||||||||||||||||||||
| 319 | defined $bindattrs->[$i] | ||||||||||||||||||||||||||||||||||||||||||
| 320 | and | ||||||||||||||||||||||||||||||||||||||||||
| 321 | defined $bind->[$i][1] | ||||||||||||||||||||||||||||||||||||||||||
| 322 | and | ||||||||||||||||||||||||||||||||||||||||||
| 323 | 120488 | grep { $bindattrs->[$i] eq $_ } ( | |||||||||||||||||||||||||||||||||||||||||
| 324 | DBI::SQL_INTEGER(), DBI::SQL_TINYINT(), DBI::SQL_SMALLINT(), DBI::SQL_BIGINT() | ||||||||||||||||||||||||||||||||||||||||||
| 325 | ) | ||||||||||||||||||||||||||||||||||||||||||
| 326 | ) { | ||||||||||||||||||||||||||||||||||||||||||
| 327 | 30122 | ▶ | if ( $bind->[$i][1] !~ /^ [\+\-]? [0-9]+ (?: \. 0* )? $/x ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 328 | carp_unique( sprintf ( | ||||||||||||||||||||||||||||||||||||||||||
| 329 | "Non-integer value supplied for column '%s' despite the integer datatype", | ||||||||||||||||||||||||||||||||||||||||||
| 330 | 2 | ▶ | $bind->[$i][0]{dbic_colname} || "# $i" | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$bind->[$i][0]{'dbic_colname'} || "# $i"
MC/DC0%0/1
$bind->[$i][0]{'dbic_colname'} || "# $i"
$bind->[$i][0]{'dbic_colname'}
Truth table50%1/2
A
A= $bind->[$i][0]{'dbic_colname'}
| |||||||||||||||||||||||||||||||||||||||||||
| 331 | ) ); | ||||||||||||||||||||||||||||||||||||||||||
| 332 | 2 | undef $bindattrs->[$i]; | |||||||||||||||||||||||||||||||||||||||||
| 333 | } | ||||||||||||||||||||||||||||||||||||||||||
| 334 | elsif ( | ||||||||||||||||||||||||||||||||||||||||||
| 335 | ! $DBD::SQLite::__DBIC_CHECK_dbd_can_bind_bigint_values | ||||||||||||||||||||||||||||||||||||||||||
| 336 | ) { | ||||||||||||||||||||||||||||||||||||||||||
| 337 | # unsigned 32 bit ints have a range of −2,147,483,648 to 2,147,483,647 | ||||||||||||||||||||||||||||||||||||||||||
| 338 | # alternatively expressed as the hexadecimal numbers below | ||||||||||||||||||||||||||||||||||||||||||
| 339 | # the comparison math will come out right regardless of ivsize, since | ||||||||||||||||||||||||||||||||||||||||||
| 340 | # we are operating within 31 bits | ||||||||||||||||||||||||||||||||||||||||||
| 341 | # P.S. 31 because one bit is lost for the sign | ||||||||||||||||||||||||||||||||||||||||||
| 342 | 0 | ▶ | if ($bind->[$i][1] > 0x7fff_ffff or $bind->[$i][1] < -0x8000_0000) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$bind->[$i][1] > 2147483647 or $bind->[$i][1] < '-2147483648'
MC/DC0%0/2
$bind->[$i][1] > 2147483647 or $bind->[$i][1] < '-2147483648'
$bind->[$i][1] > 2147483647
$bind->[$i][1] < '-2147483648'
Truth table0%0/3
A or B
A= $bind->[$i][1] > 2147483647B= $bind->[$i][1] < '-2147483648'
| |||||||||||||||||||||||||||||||||||||||||||
| 343 | carp_unique( sprintf ( | ||||||||||||||||||||||||||||||||||||||||||
| 344 | "An integer value occupying more than 32 bits was supplied for column '%s' " | ||||||||||||||||||||||||||||||||||||||||||
| 345 | . 'which your version of DBD::SQLite (%s) can not bind properly so DBIC ' | ||||||||||||||||||||||||||||||||||||||||||
| 346 | . 'will treat it as a string instead, consider upgrading to at least ' | ||||||||||||||||||||||||||||||||||||||||||
| 347 | . 'DBD::SQLite version 1.37', | ||||||||||||||||||||||||||||||||||||||||||
| 348 | 0 | ▶ | $bind->[$i][0]{dbic_colname} || "# $i", | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$bind->[$i][0]{'dbic_colname'} || "# $i"
MC/DC0%0/1
$bind->[$i][0]{'dbic_colname'} || "# $i"
$bind->[$i][0]{'dbic_colname'}
Truth table0%0/2
A
A= $bind->[$i][0]{'dbic_colname'}
| |||||||||||||||||||||||||||||||||||||||||||
| 349 | DBD::SQLite->VERSION, | ||||||||||||||||||||||||||||||||||||||||||
| 350 | ) ); | ||||||||||||||||||||||||||||||||||||||||||
| 351 | 0 | undef $bindattrs->[$i]; | |||||||||||||||||||||||||||||||||||||||||
| 352 | } | ||||||||||||||||||||||||||||||||||||||||||
| 353 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 354 | 0 | $bindattrs->[$i] = DBI::SQL_INTEGER() | |||||||||||||||||||||||||||||||||||||||||
| 355 | } | ||||||||||||||||||||||||||||||||||||||||||
| 356 | } | ||||||||||||||||||||||||||||||||||||||||||
| 357 | } | ||||||||||||||||||||||||||||||||||||||||||
| 358 | } | ||||||||||||||||||||||||||||||||||||||||||
| 359 | |||||||||||||||||||||||||||||||||||||||||||
| 360 | 17693 | return $bindattrs; | |||||||||||||||||||||||||||||||||||||||||
| 361 | } | ||||||||||||||||||||||||||||||||||||||||||
| 362 | |||||||||||||||||||||||||||||||||||||||||||
| 363 | =head2 connect_call_use_foreign_keys | ||||||||||||||||||||||||||||||||||||||||||
| 364 | |||||||||||||||||||||||||||||||||||||||||||
| 365 | Used as: | ||||||||||||||||||||||||||||||||||||||||||
| 366 | |||||||||||||||||||||||||||||||||||||||||||
| 367 | on_connect_call => 'use_foreign_keys' | ||||||||||||||||||||||||||||||||||||||||||
| 368 | |||||||||||||||||||||||||||||||||||||||||||
| 369 | In L<connect_info|DBIx::Class::Storage::DBI/connect_info> to turn on foreign key | ||||||||||||||||||||||||||||||||||||||||||
| 370 | (including cascading) support for recent versions of SQLite and L<DBD::SQLite>. | ||||||||||||||||||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||||||||||||||||
| 372 | Executes: | ||||||||||||||||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||||||||||||||||
| 374 | PRAGMA foreign_keys = ON | ||||||||||||||||||||||||||||||||||||||||||
| 375 | |||||||||||||||||||||||||||||||||||||||||||
| 376 | See L<http://www.sqlite.org/foreignkeys.html> for more information. | ||||||||||||||||||||||||||||||||||||||||||
| 377 | |||||||||||||||||||||||||||||||||||||||||||
| 378 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 379 | |||||||||||||||||||||||||||||||||||||||||||
| 380 | 0 | ▶ | sub connect_call_use_foreign_keys { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
connect_call_use_foreign_keys: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 381 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 382 | |||||||||||||||||||||||||||||||||||||||||||
| 383 | 0 | $self->_do_query( | |||||||||||||||||||||||||||||||||||||||||
| 384 | 'PRAGMA foreign_keys = ON' | ||||||||||||||||||||||||||||||||||||||||||
| 385 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 386 | } | ||||||||||||||||||||||||||||||||||||||||||
| 387 | |||||||||||||||||||||||||||||||||||||||||||
| 388 | =head1 FURTHER QUESTIONS? | ||||||||||||||||||||||||||||||||||||||||||
| 389 | |||||||||||||||||||||||||||||||||||||||||||
| 390 | Check the list of L<additional DBIC resources|DBIx::Class/GETTING HELP/SUPPORT>. | ||||||||||||||||||||||||||||||||||||||||||
| 391 | |||||||||||||||||||||||||||||||||||||||||||
| 392 | =head1 COPYRIGHT AND LICENSE | ||||||||||||||||||||||||||||||||||||||||||
| 393 | |||||||||||||||||||||||||||||||||||||||||||
| 394 | This module is free software L<copyright|DBIx::Class/COPYRIGHT AND LICENSE> | ||||||||||||||||||||||||||||||||||||||||||
| 395 | by the L<DBIx::Class (DBIC) authors|DBIx::Class/AUTHORS>. You can | ||||||||||||||||||||||||||||||||||||||||||
| 396 | redistribute it and/or modify it under the same terms as the | ||||||||||||||||||||||||||||||||||||||||||
| 397 | L<DBIx::Class library|DBIx::Class/COPYRIGHT AND LICENSE>. | ||||||||||||||||||||||||||||||||||||||||||
| 398 | |||||||||||||||||||||||||||||||||||||||||||
| 399 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 400 | |||||||||||||||||||||||||||||||||||||||||||
| 401 | 217 | 1; | |||||||||||||||||||||||||||||||||||||||||