DBIx/Class/Storage/DBI/IdentityInsert.pm

filter: Statementstmt 69.5% 16 / 23 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 83.3% 5 / 6 Podpod n/a totaltotal 67.7% 21 / 31 CC 2 SCAR 8.9
CC
2
Cov
64%
_prep_for_execute
6.0
BEGIN
1.0
BEGIN
1.0
CRAP 2.4
« DBIx/Class/Storage/DBI/ADO.pm ↑ Summary DBIx/Class/Serialize/Storable.pm »
1 package DBIx::Class::Storage::DBI::IdentityInsert;
2  
3 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 4 ▶use base 'DBIx::Class::Storage::DBI';
Subroutine BEGIN: called CC=1 SCAR=0.0
6 4 ▶use mro 'c3';
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 4 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 =head1 NAME
11  
12 DBIx::Class::Storage::DBI::IdentityInsert - Storage Component for Sybase ASE and
13 MSSQL for Identity Inserts / Updates
14  
15 =head1 DESCRIPTION
16  
17 This is a storage component for Sybase ASE
18 (L<DBIx::Class::Storage::DBI::Sybase::ASE>) and Microsoft SQL Server
19 (L<DBIx::Class::Storage::DBI::MSSQL>) to support identity inserts, that is
20 inserts of explicit values into C<IDENTITY> columns.
21  
22 This is done by wrapping C<INSERT> operations in a pair of table identity
23 toggles like:
24  
25 SET IDENTITY_INSERT $table ON
26 $sql
27 SET IDENTITY_INSERT $table OFF
28  
29 =cut
30  
31 # SET IDENTITY_X only works as part of a statement scope. We can not
32 # $dbh->do the $sql and the wrapping set()s individually. Hence the
33 # sql mangling. The newlines are important.
34 sub _prep_for_execute {
35 0 ▶ my $self = shift;
Subroutine _prep_for_execute: not called CC=2 SCAR=17.9
36  
37 0 ▶ return $self->next::method(@_) unless $self->_autoinc_supplied_for_op;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_autoinc_supplied_for_op 0 0 0
38  
39 0 my ($op, $ident) = @_;
40  
41 0 my $table = $self->sql_maker->_quote($ident->name);
42 0 $op = uc $op;
43  
44 0 my ($sql, $bind) = $self->next::method(@_);
45  
46 0 return (<<EOS, $bind);
47 SET IDENTITY_$op $table ON
48 $sql
49 SET IDENTITY_$op $table OFF
50 EOS
51  
52 }
53  
54 =head1 AUTHOR
55  
56 See L<DBIx::Class/AUTHOR> and L<DBIx::Class/CONTRIBUTORS>.
57  
58 =head1 LICENSE
59  
60 You may distribute this code under the same terms as Perl itself.
61  
62 =cut
63  
64 4 1;
« DBIx/Class/Storage/DBI/ADO.pm ↑ Summary DBIx/Class/Serialize/Storable.pm »