DBIx/Class/Storage/DBI/IdentityInsert.pm

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