DBIx/Class/Storage/DBI/SQLite.pm

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