| 1 | 6 | ▶ | use v5.36; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 2 | 6 | ▶ | use feature 'class'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 3 | 6 | ▶ | no warnings 'experimental::class'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||
| 5 | 6 | ▶ | use Azure::SDK::Storage::Tables::TransactionOperation; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||
| 7 | 6 | class Azure::SDK::Storage::Tables::Transaction { | |||||||||||||||||||||||||||||||||||||||||
| 8 | 6 | ▶ | use Carp qw(croak); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | 6 | ▶ | use Scalar::Util qw(blessed); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||
| 11 | 6 | field $operations = []; | |||||||||||||||||||||||||||||||||||||||||
| 12 | 6 | field $partition_key = undef; | |||||||||||||||||||||||||||||||||||||||||
| 13 | 6 | field $seen = {}; | |||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||
| 15 | 112 | ▶ | method insert ($entity) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
insert: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 16 | 112 | return $self->_add('insert', $entity); | |||||||||||||||||||||||||||||||||||||||||
| 17 | } | ||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||
| 19 | 2 | ▶ | method replace ($entity, %options) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
replace: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 20 | 2 | return $self->_add('replace', $entity, %options); | |||||||||||||||||||||||||||||||||||||||||
| 21 | } | ||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||
| 23 | 1 | ▶ | method merge ($entity, %options) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
merge: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 24 | 1 | return $self->_add('merge', $entity, %options); | |||||||||||||||||||||||||||||||||||||||||
| 25 | } | ||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||
| 27 | 2 | ▶ | method delete ($entity, %options) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
delete: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 28 | 2 | return $self->_add('delete', $entity, %options); | |||||||||||||||||||||||||||||||||||||||||
| 29 | } | ||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||
| 31 | 0 | ▶ | method insert_or_replace ($entity) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
insert_or_replace: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 32 | 0 | return $self->_add('insert_or_replace', $entity); | |||||||||||||||||||||||||||||||||||||||||
| 33 | } | ||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||
| 35 | 0 | ▶ | method insert_or_merge ($entity) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
insert_or_merge: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 36 | 0 | return $self->_add('insert_or_merge', $entity); | |||||||||||||||||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||
| 39 | 3 | ▶ | method operations () { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
operations: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 40 | 3 | return [$operations->@*]; | |||||||||||||||||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||
| 43 | 123 | ▶ | method count () { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
count: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 44 | 123 | return scalar $operations->@*; | |||||||||||||||||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||
| 47 | 0 | ▶ | method partition_key () { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
partition_key: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 48 | 0 | return $partition_key; | |||||||||||||||||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||
| 51 | 117 | ▶ | method _add ($action, $entity, %options) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_add: called CC=15 SCAR=27.7
| |||||||||||||||||||||||||||||||||||||||||||
| 52 | croak 'Unknown Table transaction option(s): ' . join(', ', sort keys %options) | ||||||||||||||||||||||||||||||||||||||||||
| 53 | 117 | ▶ | if grep { $_ ne 'if_match' } keys %options; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 54 | croak "Table transaction $action does not accept if_match" | ||||||||||||||||||||||||||||||||||||||||||
| 55 | if exists $options{if_match} | ||||||||||||||||||||||||||||||||||||||||||
| 56 | 117 | ▶ | && $action =~ /\A(?:insert|insert_or_replace|insert_or_merge)\z/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
exists $options{"if_match"} and $action =~ /\A(?:insert|insert_or_replace|insert_or_merge)\z/u
MC/DC0%0/2
exists $options{"if_match"} and $action =~ /\A(?:insert|insert_or_replace|insert_or_merge)\z/u
exists $options{"if_match"}
$action =~ /\A(?:insert|insert_or_replace|insert_or_merge)\z/u
Truth table66%2/3
A and B
A= exists $options{"if_match"}B= $action =~ /\A(?:insert|insert_or_replace|insert_or_merge)\z/u
| |||||||||||||||||||||||||||||||||||||||||||
| 57 | 117 | ▶ | croak 'Table transaction supports at most 100 operations' | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 58 | if $self->count >= 100; | ||||||||||||||||||||||||||||||||||||||||||
| 59 | 116 | ▶ | croak 'Table transaction operation requires an Entity' | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
builtin::blessed($entity) and $entity->isa("Azure::SDK::Storage::Tables::Entity")
MC/DC0%0/2
builtin::blessed($entity) and $entity->isa("Azure::SDK::Storage::Tables::Entity")
builtin::blessed($entity)
$entity->isa("Azure::SDK::Storage::Tables::Entity")
Truth table33%1/3
A and B
A= builtin::blessed($entity)B= $entity->isa("Azure::SDK::Storage::Tables::Entity")
| |||||||||||||||||||||||||||||||||||||||||||
| 60 | unless blessed($entity) | ||||||||||||||||||||||||||||||||||||||||||
| 61 | && $entity->isa('Azure::SDK::Storage::Tables::Entity'); | ||||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||
| 63 | 116 | ▶ | if (defined $partition_key) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 64 | 108 | ▶ | croak 'Table transaction operations must use the same partition' | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 65 | unless $entity->partition_key eq $partition_key; | ||||||||||||||||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||||||||||||||||
| 67 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 68 | 8 | $partition_key = $entity->partition_key; | |||||||||||||||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||
| 71 | 115 | my $identity = $entity->partition_key . "\0" . $entity->row_key; | |||||||||||||||||||||||||||||||||||||||||
| 72 | croak 'A Table transaction entity may appear only once' | ||||||||||||||||||||||||||||||||||||||||||
| 73 | 115 | ▶ | if $seen->{$identity}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||
| 75 | 114 | my $if_match; | |||||||||||||||||||||||||||||||||||||||||
| 76 | 114 | ▶ | if ($action =~ /\A(?:replace|merge|delete)\z/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 77 | 4 | ▶ | $if_match = $options{if_match} // $entity->etag; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$options{"if_match"} // $entity->etag
MC/DC100%2/2
$options{"if_match"} // $entity->etag
$options{"if_match"}
$entity->etag
Truth table100%3/3
A // B
A= $options{"if_match"}B= $entity->etag
| |||||||||||||||||||||||||||||||||||||||||||
| 78 | 4 | ▶ | croak "Table transaction $action if_match is required; use \"*\" for an unconditional mutation" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
defined $if_match and not ref $if_match and length $if_match
defined $if_match and not ref $if_match
MC/DC33%1/3
defined $if_match and not ref $if_match and length $if_match
defined $if_match
not ref $if_match
length $if_match
Truth table50%2/4
A and not(B) and C
A= defined $if_matchB= not ref $if_matchC= length $if_match
| |||||||||||||||||||||||||||||||||||||||||||
| 79 | unless defined $if_match && !ref($if_match) && length($if_match); | ||||||||||||||||||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||
| 82 | 112 | push $operations->@*, Azure::SDK::Storage::Tables::TransactionOperation->new( | |||||||||||||||||||||||||||||||||||||||||
| 83 | action => $action, | ||||||||||||||||||||||||||||||||||||||||||
| 84 | entity => $entity, | ||||||||||||||||||||||||||||||||||||||||||
| 85 | if_match => $if_match, | ||||||||||||||||||||||||||||||||||||||||||
| 86 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 87 | 112 | $seen->{$identity} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 88 | 112 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||
| 92 | 6 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||
| 94 | __END__ | ||||||||||||||||||||||||||||||||||||||||||