| 1 | package DBIx::Class::Helper::Row::ProxyResultSetUpdate; | ||||||||||||||
| 2 | 56 | $DBIx::Class::Helper::Row::ProxyResultSetUpdate::VERSION = '2.037000'; | |||||||||||||
| 3 | # ABSTRACT: Efficiently reuse ResultSet updates from results | ||||||||||||||
| 4 | |||||||||||||||
| 5 | 56 | ▶ | use strict; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 6 | 56 | ▶ | use warnings; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 7 | |||||||||||||||
| 8 | 56 | ▶ | use parent 'DBIx::Class::Helper::Row::SelfResultSet', 'DBIx::Class::Row'; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 9 | |||||||||||||||
| 10 | 2 | ▶ | sub update { | ||||||||||||
|
Subroutine
update: called CC=6 SCAR=18.6
Pod
documented
| |||||||||||||||
| 11 | 2 | my ($self, $upd) = @_; | |||||||||||||
| 12 | |||||||||||||||
| 13 | 2 | ▶ | $self->set_inflated_columns($upd) if $upd; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 14 | |||||||||||||||
| 15 | 2 | ▶ | my %to_update = $self->get_dirty_columns | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 16 | or return $self; | ||||||||||||||
| 17 | |||||||||||||||
| 18 | 2 | ▶ | $self->throw_exception( "Not in database" ) unless $self->in_storage; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 19 | |||||||||||||||
| 20 | # copied directly from DBIx::Class::Row except for this line | ||||||||||||||
| 21 | 2 | my $rows = $self->self_rs->update(\%to_update); | |||||||||||||
| 22 | 2 | ▶ | if ($rows == 0) { | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 23 | 1 | $self->throw_exception( "Can't update ${self}: row not found" ); | |||||||||||||
| 24 | } elsif ($rows > 1) { | ||||||||||||||
| 25 | 0 | $self->throw_exception("Can't update ${self}: updated more than one row"); | |||||||||||||
| 26 | } | ||||||||||||||
| 27 | 1 | $self->{_dirty_columns} = {}; | |||||||||||||
| 28 | 1 | $self->{related_resultsets} = {}; | |||||||||||||
| 29 | 1 | delete $self->{_column_data_in_storage}; | |||||||||||||
| 30 | 1 | return $self; | |||||||||||||
| 31 | } | ||||||||||||||
| 32 | |||||||||||||||
| 33 | 56 | 1; | |||||||||||||
| 34 | |||||||||||||||
| 35 | __END__ | ||||||||||||||