SPOPS/Key/DBI/HandleField.pm untested

filter: Statementstmt 0.0% 0 / 26 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 0.0% 0 / 5 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 47 CC 3 SCAR 18.4
CC
3
Cov
0%
post_fetch_id
12.0
pre_fetch_id
2.0
BEGIN
2.0
CRAP 6.3
1 package SPOPS::Key::DBI::HandleField;
2  
3 # $Id: HandleField.pm,v 3.5 2004/06/02 00:48:23 lachoy Exp $
4  
5 use strict;
6 use Log::Log4perl qw( get_logger );
7 use SPOPS;
8  
9 my $log = get_logger();
10  
11 $SPOPS::Key::DBI::HandleField::VERSION = sprintf("%d.%02d", q$Revision: 3.5 $ =~ /(\d+)\.(\d+)/);
12  
13 # Ensure only POST_fetch_id used
14  
15 sub pre_fetch_id { return undef }
16  
17 # Retrieve the value of the just-inserted ID
18  
19 sub post_fetch_id {
20 my ( $self, $p ) = @_;
21 my $field = $self->CONFIG->{handle_field};
22 unless ( $field ) {
23 SPOPS::Exception->throw( 'Cannot retrieve ID since handle field is unknown' );
24 }
25 my ( $id );
26 $id = eval { $p->{db}->{ $field } };
27 $id ||= eval { $p->{statement}->{ $field } };
28 $log->is_info &&
29 $log->info( "Found inserted ID ($id)" );
30 unless ( $id ) {
31 SPOPS::Exception->throw( "Cannot find ID value in $field" );
32 }
33 return $id;
34 }
35  
36 1;
37  
38 __END__