| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package # hide from PAUSE |
|
2
|
|
|
|
|
|
|
DBIx::Class::CDBICompat::TempColumns; |
|
3
|
|
|
|
|
|
|
|
|
4
|
2
|
|
|
2
|
|
815
|
use strict; |
|
|
2
|
|
|
|
|
5
|
|
|
|
2
|
|
|
|
|
71
|
|
|
5
|
2
|
|
|
2
|
|
10
|
use warnings; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
46
|
|
|
6
|
2
|
|
|
2
|
|
9
|
use base 'DBIx::Class'; |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
169
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
2
|
|
|
2
|
|
14
|
use Carp; |
|
|
2
|
|
|
|
|
5
|
|
|
|
2
|
|
|
|
|
138
|
|
|
9
|
2
|
|
|
2
|
|
17
|
use namespace::clean; |
|
|
2
|
|
|
|
|
8
|
|
|
|
2
|
|
|
|
|
15
|
|
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
__PACKAGE__->mk_classdata('_temp_columns' => { }); |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub _add_column_group { |
|
14
|
0
|
|
|
0
|
|
|
my ($class, $group, @cols) = @_; |
|
15
|
|
|
|
|
|
|
|
|
16
|
0
|
0
|
|
|
|
|
return $class->next::method($group, @cols) unless $group eq 'TEMP'; |
|
17
|
|
|
|
|
|
|
|
|
18
|
0
|
|
|
|
|
|
my %new_cols = map { $_ => 1 } @cols; |
|
|
0
|
|
|
|
|
|
|
|
19
|
0
|
|
|
|
|
|
my %tmp_cols = %{$class->_temp_columns}; |
|
|
0
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
|
|
21
|
0
|
|
|
|
|
|
for my $existing_col ( grep $new_cols{$_}, $class->columns ) { |
|
22
|
|
|
|
|
|
|
# Already been declared TEMP |
|
23
|
0
|
0
|
|
|
|
|
next if $tmp_cols{$existing_col}; |
|
24
|
|
|
|
|
|
|
|
|
25
|
0
|
|
|
|
|
|
carp "Declaring column $existing_col as TEMP but it already exists"; |
|
26
|
|
|
|
|
|
|
} |
|
27
|
|
|
|
|
|
|
|
|
28
|
0
|
|
|
|
|
|
$class->_register_column_group($group => @cols); |
|
29
|
0
|
|
|
|
|
|
$class->mk_group_accessors('temp' => @cols); |
|
30
|
|
|
|
|
|
|
|
|
31
|
0
|
|
|
|
|
|
$class->_temp_columns({ %tmp_cols, %new_cols }); |
|
32
|
|
|
|
|
|
|
} |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub new { |
|
35
|
0
|
|
|
0
|
0
|
|
my ($class, $attrs, @rest) = @_; |
|
36
|
|
|
|
|
|
|
|
|
37
|
0
|
|
|
|
|
|
my $temp = $class->_extract_temp_data($attrs); |
|
38
|
|
|
|
|
|
|
|
|
39
|
0
|
|
|
|
|
|
my $new = $class->next::method($attrs, @rest); |
|
40
|
|
|
|
|
|
|
|
|
41
|
0
|
|
|
|
|
|
$new->set_temp($_, $temp->{$_}) for keys %$temp; |
|
42
|
|
|
|
|
|
|
|
|
43
|
0
|
|
|
|
|
|
return $new; |
|
44
|
|
|
|
|
|
|
} |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub _extract_temp_data { |
|
47
|
0
|
|
|
0
|
|
|
my($self, $data) = @_; |
|
48
|
|
|
|
|
|
|
|
|
49
|
0
|
|
|
|
|
|
my %temp; |
|
50
|
0
|
|
|
|
|
|
foreach my $key (keys %$data) { |
|
51
|
0
|
0
|
|
|
|
|
$temp{$key} = delete $data->{$key} if $self->_temp_columns->{$key}; |
|
52
|
|
|
|
|
|
|
} |
|
53
|
|
|
|
|
|
|
|
|
54
|
0
|
|
|
|
|
|
return \%temp; |
|
55
|
|
|
|
|
|
|
} |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub find_column { |
|
58
|
0
|
|
|
0
|
0
|
|
my ($class, $col, @rest) = @_; |
|
59
|
0
|
0
|
|
|
|
|
return $col if $class->_temp_columns->{$col}; |
|
60
|
0
|
|
|
|
|
|
return $class->next::method($col, @rest); |
|
61
|
|
|
|
|
|
|
} |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub set { |
|
64
|
0
|
|
|
0
|
0
|
|
my($self, %data) = @_; |
|
65
|
|
|
|
|
|
|
|
|
66
|
0
|
|
|
|
|
|
my $temp_data = $self->_extract_temp_data(\%data); |
|
67
|
|
|
|
|
|
|
|
|
68
|
0
|
|
|
|
|
|
$self->set_temp($_, $temp_data->{$_}) for keys %$temp_data; |
|
69
|
|
|
|
|
|
|
|
|
70
|
0
|
|
|
|
|
|
return $self->next::method(%data); |
|
71
|
|
|
|
|
|
|
} |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub get_temp { |
|
74
|
0
|
|
|
0
|
0
|
|
my ($self, $column) = @_; |
|
75
|
0
|
0
|
|
|
|
|
$self->throw_exception( "Can't fetch data as class method" ) unless ref $self; |
|
76
|
0
|
0
|
|
|
|
|
$self->throw_exception( "No such TEMP column '${column}'" ) unless $self->_temp_columns->{$column} ; |
|
77
|
|
|
|
|
|
|
return $self->{_temp_column_data}{$column} |
|
78
|
0
|
0
|
|
|
|
|
if exists $self->{_temp_column_data}{$column}; |
|
79
|
0
|
|
|
|
|
|
return undef; |
|
80
|
|
|
|
|
|
|
} |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
sub set_temp { |
|
83
|
0
|
|
|
0
|
0
|
|
my ($self, $column, $value) = @_; |
|
84
|
|
|
|
|
|
|
$self->throw_exception( "No such TEMP column '${column}'" ) |
|
85
|
0
|
0
|
|
|
|
|
unless $self->_temp_columns->{$column}; |
|
86
|
0
|
0
|
|
|
|
|
$self->throw_exception( "set_temp called for ${column} without value" ) |
|
87
|
|
|
|
|
|
|
if @_ < 3; |
|
88
|
0
|
|
|
|
|
|
return $self->{_temp_column_data}{$column} = $value; |
|
89
|
|
|
|
|
|
|
} |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
sub has_real_column { |
|
92
|
0
|
0
|
|
0
|
0
|
|
return 1 if shift->has_column(shift); |
|
93
|
|
|
|
|
|
|
} |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
1; |