| 1 | package DBIx::ActiveRecord::Arel::Query::Update; | ||||||||||
| 2 | 2 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | 2 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 2 | ▶ | use base 'DBIx::ActiveRecord::Arel::Query'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | |||||||||||
| 6 | 1 | ▶ | sub new { | ||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 7 | 1 | my ($self, $main, $hash, $columns) = @_; | |||||||||
| 8 | 1 | my $o = $self->SUPER::new($main); | |||||||||
| 9 | 1 | $o->merge($main->query); | |||||||||
| 10 | 1 | $o->{hash} = $hash; | |||||||||
| 11 | 1 | $o->{columns} = $columns; | |||||||||
| 12 | 1 | $o; | |||||||||
| 13 | } | ||||||||||
| 14 | |||||||||||
| 15 | 1 | ▶ | sub columns {shift->{columns}} | ||||||||
|
Subroutine
columns: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 16 | 2 | ▶ | sub hash {shift->{hash}} | ||||||||
|
Subroutine
hash: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 17 | |||||||||||
| 18 | 1 | ▶ | sub _to_sql { | ||||||||
|
Subroutine
_to_sql: called CC=3 SCAR=11.2
| |||||||||||
| 19 | 1 | my ($self) = @_; | |||||||||
| 20 | |||||||||||
| 21 | 1 | $DBIx::ActiveRecord::Arel::Column::USE_FULL_NAME = 0; | |||||||||
| 22 | 1 | $DBIx::ActiveRecord::Arel::Column::AS = {}; | |||||||||
| 23 | |||||||||||
| 24 | 0 | ▶ | my @keys = $self->columns ? grep {exists $self->hash->{$_}} @{$self->columns} : keys %{$self->hash}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 25 | 1 | my @set = map {$_.' = ?'} @keys; | |||||||||
| 26 | 1 | my $sql = 'UPDATE '.$self->main->table.' SET '.join(', ', @set); | |||||||||
| 27 | 1 | my $where = $self->build_where; | |||||||||
| 28 | 1 | ▶ | $sql .= " WHERE $where" if $where; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 29 | 1 | unshift @{$self->{binds}}, map {$self->hash->{$_}} @keys; | |||||||||
| 30 | 1 | $sql; | |||||||||
| 31 | } | ||||||||||
| 32 | |||||||||||
| 33 | 2 | 1; | |||||||||