line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package # hide from PAUSE |
2
|
|
|
|
|
|
|
DBIx::Class::CDBICompat::LazyLoading; |
3
|
|
|
|
|
|
|
|
4
|
2
|
|
|
2
|
|
907
|
use strict; |
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
78
|
|
5
|
2
|
|
|
2
|
|
15
|
use warnings; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
62
|
|
6
|
|
|
|
|
|
|
|
7
|
2
|
|
|
2
|
|
14
|
use base 'DBIx::Class'; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
1397
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub resultset_instance { |
10
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
11
|
0
|
|
|
|
|
|
$self->next::method(@_) |
12
|
|
|
|
|
|
|
->search_rs(undef, { columns => [ $self->columns('Essential') ] }); |
13
|
|
|
|
|
|
|
} |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
# Emulate that CDBI throws out all changed columns and reloads them on |
17
|
|
|
|
|
|
|
# request in case the database modifies the new value (say, via a trigger) |
18
|
|
|
|
|
|
|
sub update { |
19
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
20
|
|
|
|
|
|
|
|
21
|
0
|
|
|
|
|
|
my @dirty_columns = keys %{$self->{_dirty_columns}}; |
|
0
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
|
23
|
0
|
|
|
|
|
|
my $ret = $self->next::method(@_); |
24
|
0
|
|
|
|
|
|
$self->_clear_column_data(@dirty_columns); |
25
|
|
|
|
|
|
|
|
26
|
0
|
|
|
|
|
|
return $ret; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
# And again for create |
31
|
|
|
|
|
|
|
sub create { |
32
|
0
|
|
|
0
|
0
|
|
my $class = shift; |
33
|
0
|
|
|
|
|
|
my($data) = @_; |
34
|
|
|
|
|
|
|
|
35
|
0
|
|
|
|
|
|
my @columns = keys %$data; |
36
|
|
|
|
|
|
|
|
37
|
0
|
|
|
|
|
|
my $obj = $class->next::method(@_); |
38
|
0
|
0
|
|
|
|
|
return $obj unless defined $obj; |
39
|
|
|
|
|
|
|
|
40
|
0
|
|
|
|
|
|
my %primary_cols = map { $_ => 1 } $class->primary_columns; |
|
0
|
|
|
|
|
|
|
41
|
0
|
|
|
|
|
|
my @data_cols = grep !$primary_cols{$_}, @columns; |
42
|
0
|
|
|
|
|
|
$obj->_clear_column_data(@data_cols); |
43
|
|
|
|
|
|
|
|
44
|
0
|
|
|
|
|
|
return $obj; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub _clear_column_data { |
49
|
0
|
|
|
0
|
|
|
my $self = shift; |
50
|
|
|
|
|
|
|
|
51
|
0
|
|
|
|
|
|
delete $self->{_column_data}{$_} for @_; |
52
|
0
|
|
|
|
|
|
delete $self->{_inflated_column}{$_} for @_; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub get_column { |
57
|
0
|
|
|
0
|
0
|
|
my ($self, $col) = @_; |
58
|
0
|
0
|
0
|
|
|
|
if ((ref $self) && (!exists $self->{'_column_data'}{$col}) |
|
|
|
0
|
|
|
|
|
59
|
|
|
|
|
|
|
&& $self->{'_in_storage'}) { |
60
|
0
|
0
|
|
|
|
|
$self->_flesh(grep { exists $self->_column_groups->{$_}{$col} |
61
|
|
|
|
|
|
|
&& $_ ne 'All' } |
62
|
0
|
0
|
|
|
|
|
keys %{ $self->_column_groups || {} }); |
|
0
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
} |
64
|
0
|
|
|
|
|
|
$self->next::method(@_[1..$#_]); |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
# CDBI does not explicitly declare auto increment columns, so |
68
|
|
|
|
|
|
|
# we just clear out our primary columns before copying. |
69
|
|
|
|
|
|
|
sub copy { |
70
|
0
|
|
|
0
|
0
|
|
my($self, $changes) = @_; |
71
|
|
|
|
|
|
|
|
72
|
0
|
|
|
|
|
|
for my $col ($self->primary_columns) { |
73
|
0
|
0
|
|
|
|
|
$changes->{$col} = undef unless exists $changes->{$col}; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
0
|
|
|
|
|
|
return $self->next::method($changes); |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub discard_changes { |
80
|
0
|
|
|
0
|
0
|
|
my($self) = shift; |
81
|
|
|
|
|
|
|
|
82
|
0
|
|
|
|
|
|
delete $self->{_column_data}{$_} for $self->is_changed; |
83
|
0
|
|
|
|
|
|
delete $self->{_dirty_columns}; |
84
|
0
|
|
|
|
|
|
delete $self->{_relationship_data}; |
85
|
|
|
|
|
|
|
|
86
|
0
|
|
|
|
|
|
return $self; |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
sub _ident_cond { |
90
|
0
|
|
|
0
|
|
|
my ($class) = @_; |
91
|
0
|
|
|
|
|
|
return join(" AND ", map { "$_ = ?" } $class->primary_columns); |
|
0
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
sub _flesh { |
95
|
0
|
|
|
0
|
|
|
my ($self, @groups) = @_; |
96
|
0
|
0
|
|
|
|
|
@groups = ('All') unless @groups; |
97
|
0
|
|
|
|
|
|
my %want; |
98
|
0
|
|
|
|
|
|
$want{$_} = 1 for map { keys %{$self->_column_groups->{$_}} } @groups; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
99
|
0
|
0
|
|
|
|
|
if (my @want = grep { !exists $self->{'_column_data'}{$_} } keys %want) { |
|
0
|
|
|
|
|
|
|
100
|
0
|
|
|
|
|
|
my $cursor = $self->result_source->schema->storage->select( |
101
|
|
|
|
|
|
|
$self->result_source->name, \@want, |
102
|
|
|
|
|
|
|
\$self->_ident_cond, { bind => [ $self->_ident_values ] }); |
103
|
|
|
|
|
|
|
#my $sth = $self->storage->select($self->_table_name, \@want, |
104
|
|
|
|
|
|
|
# $self->ident_condition); |
105
|
|
|
|
|
|
|
# Not sure why the first one works and this doesn't :( |
106
|
0
|
|
|
|
|
|
my @val = $cursor->next; |
107
|
|
|
|
|
|
|
|
108
|
0
|
0
|
|
|
|
|
return unless @val; # object must have been deleted from the database |
109
|
|
|
|
|
|
|
|
110
|
0
|
|
|
|
|
|
foreach my $w (@want) { |
111
|
0
|
|
|
|
|
|
$self->{'_column_data'}{$w} = shift @val; |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
1; |