SDK/Storage/Tables.pm

filter: Statementstmt 95.6% 222 / 232 Branchbran 75.0% 78 / 104 Conditioncond 48.2% 56 / 116 MC/DCmcdc 26.2% 16 / 61 Subroutinesub 97.8% 46 / 47 Podpod 0.0% 0 / 14 totaltotal 72.8% 418 / 574 CC 94 SCAR 22.9
CC
94
Cov
79%
__ANON__
22.7
insert_entity
19.8
_select
18.3
CRAP 9.9
« SDK/Storage/Blobs.pm ↑ Summary SDK/Core/Transport/Default.pm »
1 4 ▶use v5.36;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 4 ▶use feature 'class';
Subroutine BEGIN: called CC=1 SCAR=0.0
3 4 ▶no warnings 'experimental::class';
Subroutine BEGIN: called CC=1 SCAR=0.0
4
5 4 ▶use Azure::SDK::Core;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 4 ▶use Azure::SDK::Core::ClientOptions;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 4 ▶use Azure::SDK::Core::Pager;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 4 ▶use Azure::SDK::Core::Request;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 4 ▶use Azure::SDK::Core::Credential::Sas;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 4 ▶use Azure::SDK::Storage::Tables::ConnectionString;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 4 ▶use Azure::SDK::Storage::Tables::Entity;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 4 ▶use Azure::SDK::Storage::Tables::EntityContinuation;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 4 ▶use Azure::SDK::Storage::Tables::Filter;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 4 ▶use Azure::SDK::Storage::Tables::Serializer;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 4 ▶use Azure::SDK::Storage::Tables::SharedKey;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 4 ▶use Azure::SDK::Storage::Tables::Transaction;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 4 ▶use Azure::SDK::Storage::Tables::Uri;
Subroutine BEGIN: called CC=1 SCAR=0.0
18
19 4 class Azure::SDK::Storage::Tables {
20 4 ▶ use Carp qw(croak);
Subroutine BEGIN: called CC=1 SCAR=0.0
21 4 ▶ use Scalar::Util qw(blessed);
Subroutine BEGIN: called CC=1 SCAR=0.0
22 4 ▶ use URI ();
Subroutine BEGIN: called CC=1 SCAR=0.0
23
24 4 ▶ use constant API_VERSION => '2025-11-05';
Subroutine BEGIN: called CC=1 SCAR=0.0
25
26 4 field $connection_string :param = undef;
27 4 field $endpoint :param = undef;
28 4 field $credential :param = undef;
29 4 field $options :param = undef;
30
31 4 field $connection :reader = undef;
32 4 field $uri :reader = undef;
33 4 field $serializer :reader = undef;
34 4 field $core :reader = undef;
35
36 32 ▶ ADJUST {
Subroutine __ANON__: called CC=19 SCAR=31.2
37 32 ▶ croak 'Table connection_string cannot be combined with endpoint or credential'
Branch: 1 branch
BranchTrueFalseTotal
if defined $connection_string and defined $endpoint || defined $credential 1 31 32
Condition83%5/6
defined $connection_string and defined $endpoint || defined $credential
!ll&&!rl&&r
11201
defined $endpoint or defined $credential
l!l&&r!l&&!r
1020
MC/DC66%2/3
defined $connection_string and defined $endpoint || defined $credential
defined $connection_string defined $endpoint defined $credential
Truth table75%3/4
A and B or C
A= defined $connection_stringB= defined $endpointC= defined $credential
ABCresult
0XX0
1000
11X1
1011
38 if defined $connection_string && (defined $endpoint || defined $credential);
39
40 31 my $auth_credential;
41 my @signers;
42 31 ▶ if (defined $connection_string) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $connection_string) { } 20 11 31
43 20 ▶ $connection = blessed($connection_string)
Branch: 1 branch
BranchTrueFalseTotal
builtin::blessed($connection_string) && $connection_string->isa('Azure::SDK::Storage::Tables::ConnectionString') ? : 0 20 20
Condition33%1/3
builtin::blessed($connection_string) and $connection_string->isa("Azure::SDK::Storage::Tables::ConnectionString")
!ll&&!rl&&r
2000
MC/DC0%0/2
builtin::blessed($connection_string) and $connection_string->isa("Azure::SDK::Storage::Tables::ConnectionString")
builtin::blessed($connection_string) $connection_string->isa("Azure::SDK::Storage::Tables::ConnectionString")
Truth table33%1/3
A and B
A= builtin::blessed($connection_string)B= $connection_string->isa("Azure::SDK::Storage::Tables::ConnectionString")
ABresult
0X0
100
111
44 && $connection_string->isa('Azure::SDK::Storage::Tables::ConnectionString')
45 ? $connection_string
46 : Azure::SDK::Storage::Tables::ConnectionString->parse($connection_string);
47 17 $uri = Azure::SDK::Storage::Tables::Uri->from_connection_string($connection);
48 17 $auth_credential = $connection->credential;
49 17 ▶ push @signers, Azure::SDK::Storage::Tables::SharedKey->new(
Branch: 1 branch
BranchTrueFalseTotal
if $auth_credential->isa("Azure::SDK::Core::Credential::SharedKey") 15 2 17
50 credential => $auth_credential,
51 api_version => API_VERSION,
52 ) if $auth_credential->isa('Azure::SDK::Core::Credential::SharedKey');
53 }
54 else {
55 11 ▶ croak 'Table endpoint is required for SAS authentication'
Branch: 1 branch
BranchTrueFalseTotal
unless defined $endpoint and length $endpoint 0 11 11
Condition33%1/3
defined $endpoint and length $endpoint
!ll&&!rl&&r
0011
MC/DC0%0/2
defined $endpoint and length $endpoint
defined $endpoint length $endpoint
Truth table33%1/3
A and B
A= defined $endpointB= length $endpoint
ABresult
0X0
100
111
56 unless defined $endpoint && length $endpoint;
57 11 my $sas_url = URI->new($endpoint);
58 11 my $sas_token = $sas_url->query;
59 11 ▶ croak 'Table SAS URL cannot be combined with a credential'
Branch: 1 branch
BranchTrueFalseTotal
if defined $sas_token and defined $credential 1 10 11
Condition100%3/3
defined $sas_token and defined $credential
!ll&&!rl&&r
281
MC/DC100%2/2
defined $sas_token and defined $credential
defined $sas_token defined $credential
Truth table100%3/3
A and B
A= defined $sas_tokenB= defined $credential
ABresult
0X0
100
111
60 if defined $sas_token && defined $credential;
61 10 ▶ if (defined $sas_token) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $sas_token) { } 8 2 10
62 8 $sas_url->query(undef);
63 8 $auth_credential = Azure::SDK::Core::Credential::Sas->new(token => $sas_token);
64 5 $endpoint = $sas_url->as_string;
65 }
66 else {
67 2 ▶ croak 'Table endpoint requires a SAS credential'
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($credential) and $credential->isa("Azure::SDK::Core::Credential::Sas") 0 2 2
Condition33%1/3
builtin::blessed($credential) and $credential->isa("Azure::SDK::Core::Credential::Sas")
!ll&&!rl&&r
002
MC/DC0%0/2
builtin::blessed($credential) and $credential->isa("Azure::SDK::Core::Credential::Sas")
builtin::blessed($credential) $credential->isa("Azure::SDK::Core::Credential::Sas")
Truth table33%1/3
A and B
A= builtin::blessed($credential)B= $credential->isa("Azure::SDK::Core::Credential::Sas")
ABresult
0X0
100
111
68 unless blessed($credential)
69 && $credential->isa('Azure::SDK::Core::Credential::Sas');
70 2 $auth_credential = $credential;
71 }
72 7 $uri = Azure::SDK::Storage::Tables::Uri->new(endpoint => $endpoint);
73 }
74 22 ▶ $auth_credential = $auth_credential->bound_to($uri->endpoint)
Branch: 1 branch
BranchTrueFalseTotal
if $auth_credential->isa("Azure::SDK::Core::Credential::Sas") 7 15 22
75 if $auth_credential->isa('Azure::SDK::Core::Credential::Sas');
76 21 $serializer = Azure::SDK::Storage::Tables::Serializer->new;
77
78 21 ▶ my $base = $options // Azure::SDK::Core::ClientOptions->new;
Condition33%1/3
$options // "Azure::SDK::Core::ClientOptions"->new
l!l&&r!l&&!r
2100
MC/DC0%0/2
$options // "Azure::SDK::Core::ClientOptions"->new
$options "Azure::SDK::Core::ClientOptions"->new
Truth table33%1/3
A // B
A= $optionsB= "Azure::SDK::Core::ClientOptions"->new
ABresult
1X1
011
000
79 21 ▶ croak 'Azure::SDK::Storage::Tables options must be ClientOptions'
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($base) and $base->isa("Azure::SDK::Core::ClientOptions") 0 21 21
Condition33%1/3
builtin::blessed($base) and $base->isa("Azure::SDK::Core::ClientOptions")
!ll&&!rl&&r
0021
MC/DC0%0/2
builtin::blessed($base) and $base->isa("Azure::SDK::Core::ClientOptions")
builtin::blessed($base) $base->isa("Azure::SDK::Core::ClientOptions")
Truth table33%1/3
A and B
A= builtin::blessed($base)B= $base->isa("Azure::SDK::Core::ClientOptions")
ABresult
0X0
100
111
80 unless blessed($base) && $base->isa('Azure::SDK::Core::ClientOptions');
81
82 21 my %default_headers = (
83 'Accept' => 'application/json;odata=nometadata',
84 'DataServiceVersion' => '3.0;NetFx',
85 'MaxDataServiceVersion' => '3.0;NetFx',
86 'x-ms-version' => API_VERSION,
87 $base->default_headers->%*,
88 );
89
90 21 my $client_options = Azure::SDK::Core::ClientOptions->new(
91 api_version => API_VERSION,
92 diagnostics_enabled => $base->diagnostics_enabled,
93 user_agent => $base->user_agent,
94 max_retries => $base->max_retries,
95 base_delay => $base->base_delay,
96 default_headers => \%default_headers,
97 transport => $base->transport,
98 credential => $auth_credential,
99 logger => $base->logger,
100 max_response_bytes => $base->max_response_bytes,
101 per_call_policies => $base->per_call_policies,
102 per_try_policies => [ $base->per_try_policies->@*, @signers ],
103 );
104
105 21 $core = Azure::SDK::Core->new(
106 endpoint => $uri->endpoint,
107 options => $client_options,
108 );
109 }
110
111 7 ▶ method create_table ($table, %options) {
Subroutine create_table: called CC=7 SCAR=22.0
Pod undocumented
112 7 _reject_unknown_options(\%options, 'if_not_exists');
113 6 $uri->validate_table_name($table);
114 5 my $target = $uri->for_tables;
115 5 my $body = $serializer->serialize_table($table);
116
117 5 my $response = eval {
118 5 $self->_send(
119 method => 'POST',
120 target => $target,
121 headers => {
122 'Content-Length' => length($body),
123 'Content-Type' => 'application/json',
124 'Prefer' => 'return-no-content',
125 },
126 body => $body,
127 );
128 };
129 5 my $error = $@;
130 5 ▶ if ($error) {
Branch: 1 branch
BranchTrueFalseTotal
if ($error) 1 4 5
131 return undef
132 if $options{if_not_exists}
133 1 ▶ && blessed($error)
Branch: 1 branch
BranchTrueFalseTotal
if $options{"if_not_exists"} and builtin::blessed($error) and $error->isa("Azure::SDK::Core::Error") and ($error->code // "") eq "TableAlreadyExists" 1 0 1
Condition36%4/11
$options{"if_not_exists"} and builtin::blessed($error) and $error->isa("Azure::SDK::Core::Error") and ($error->code // "") eq "TableAlreadyExists"
!ll&&!rl&&r
001
$options{"if_not_exists"} and builtin::blessed($error) and $error->isa("Azure::SDK::Core::Error")
!ll&&!rl&&r
001
$options{"if_not_exists"} and builtin::blessed($error)
!ll&&!rl&&r
001
$error->code // ""
l!l
10
MC/DC0%0/4
$options{"if_not_exists"} and builtin::blessed($error) and $error->isa("Azure::SDK::Core::Error") and ($error->code // "") eq "TableAlreadyExists"
$options{"if_not_exists"} builtin::blessed($error) $error->isa("Azure::SDK::Core::Error") $error->code
Truth table20%1/5
A and B and C and D
A= $options{"if_not_exists"}B= builtin::blessed($error)C= $error->isa("Azure::SDK::Core::Error")D= $error->code
ABCDresult
0XXX0
10XX0
110X0
11100
11111
134 && $error->isa('Azure::SDK::Core::Error')
135 && ($error->code // '') eq 'TableAlreadyExists';
136 0 die $error;
137 }
138 4 return $response;
139 }
140
141 3 ▶ method delete_table ($table, %options) {
Subroutine delete_table: called CC=2 SCAR=7.2
Pod undocumented
142 3 _reject_unknown_options(\%options, 'if_exists');
143 return $self->_send(
144 method => 'DELETE',
145 target => $uri->for_table($table),
146 headers => { 'Content-Type' => 'application/json' },
147 ignored_codes => $options{if_exists}
148 3 ▶ ? [qw(TableNotFound ResourceNotFound)]
Branch: 1 branch
BranchTrueFalseTotal
$options{'if_exists'} ? : 3 0 3
149 : undef,
150 );
151 }
152
153 8 ▶ method list_tables (%options) {
Subroutine list_tables: called CC=4 SCAR=13.9
Pod undocumented
154 8 _reject_unknown_options(
155 \%options,
156 qw(filter max_results next_table_name),
157 );
158
159 8 my %query;
160 $query{'$filter'} = _query_value('list_tables filter', $options{filter})
161 8 ▶ if defined $options{filter};
Branch: 1 branch
BranchTrueFalseTotal
if defined $options{"filter"} 4 4 8
162 $query{NextTableName} = _query_value(
163 'list_tables next_table_name',
164 $options{next_table_name},
165 6 ▶ ) if defined $options{next_table_name};
Branch: 1 branch
BranchTrueFalseTotal
if defined $options{"next_table_name"} 3 3 6
166 6 ▶ if (defined $options{max_results}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $options{"max_results"}) 6 0 6
167 $query{'$top'} = _integer_between(
168 'list_tables max_results',
169 $options{max_results},
170 6 1,
171 1000,
172 );
173 }
174
175 4 my $response = $self->_send(
176 method => 'GET',
177 target => $uri->for_tables(\%query),
178 );
179 4 return $serializer->parse_table_list(
180 $response->body,
181 $response->header('x-ms-continuation-NextTableName'),
182 );
183 }
184
185 2 ▶ method list_tables_pager (%options) {
Subroutine list_tables_pager: called CC=1 SCAR=0.0
Pod undocumented
186 2 _reject_unknown_options(
187 \%options,
188 qw(filter max_results next_table_name),
189 );
190
191 2 my $continuation_token = delete $options{next_table_name};
192 return Azure::SDK::Core::Pager->new(
193 continuation_token => $continuation_token,
194 4 ▶ fetch_page => sub ($token) {
Subroutine __ANON__: called CC=2 SCAR=6.9
195 4 my %page_options = %options;
196 4 ▶ $page_options{next_table_name} = $token if defined $token;
Branch: 1 branch
BranchTrueFalseTotal
if defined $token 3 1 4
197 4 return $self->list_tables(%page_options);
198 },
199 2 );
200 }
201
202 1 ▶ method list_all_tables (%options) {
Subroutine list_all_tables: called CC=2 SCAR=6.9
Pod undocumented
203 1 my $pager = $self->list_tables_pager(%options);
204 1 my @items;
205 1 ▶ while (defined(my $item = $pager->next_item)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $item = $pager->next_item)) 2 1 3
206 2 push @items, $item;
207 }
208 1 return \@items;
209 }
210
211 3 ▶ method insert_entity ($table, $entity, %options) {
Subroutine insert_entity: called CC=7 SCAR=29.9
Pod undocumented
212 3 _reject_unknown_options(\%options, 'if_not_exists');
213 2 _require_entity($entity);
214 1 my $body = $serializer->serialize_entity($entity);
215
216 1 my $response = eval {
217 1 $self->_send(
218 method => 'POST',
219 target => $uri->for_insert($table),
220 headers => _entity_body_headers($body),
221 body => $body,
222 );
223 };
224 1 my $error = $@;
225 1 ▶ if ($error) {
Branch: 1 branch
BranchTrueFalseTotal
if ($error) 0 1 1
226 return undef
227 if $options{if_not_exists}
228 0 ▶ && blessed($error)
Branch: 1 branch
BranchTrueFalseTotal
if $options{"if_not_exists"} and builtin::blessed($error) and $error->isa("Azure::SDK::Core::Error") and ($error->code // "") eq "EntityAlreadyExists" 0 0 0
Condition0%0/11
$options{"if_not_exists"} and builtin::blessed($error) and $error->isa("Azure::SDK::Core::Error") and ($error->code // "") eq "EntityAlreadyExists"
!ll&&!rl&&r
000
$options{"if_not_exists"} and builtin::blessed($error) and $error->isa("Azure::SDK::Core::Error")
!ll&&!rl&&r
000
$options{"if_not_exists"} and builtin::blessed($error)
!ll&&!rl&&r
000
$error->code // ""
l!l
00
MC/DC0%0/4
$options{"if_not_exists"} and builtin::blessed($error) and $error->isa("Azure::SDK::Core::Error") and ($error->code // "") eq "EntityAlreadyExists"
$options{"if_not_exists"} builtin::blessed($error) $error->isa("Azure::SDK::Core::Error") $error->code
Truth table0%0/5
A and B and C and D
A= $options{"if_not_exists"}B= builtin::blessed($error)C= $error->isa("Azure::SDK::Core::Error")D= $error->code
ABCDresult
0XXX0
10XX0
110X0
11100
11111
229 && $error->isa('Azure::SDK::Core::Error')
230 && ($error->code // '') eq 'EntityAlreadyExists';
231 0 die $error;
232 }
233 1 return $entity->with_etag($response->header('ETag'));
234 }
235
236 4 ▶ method get_entity ($table, $partition_key, $row_key, %options) {
Subroutine get_entity: called CC=2 SCAR=7.0
Pod undocumented
237 4 _reject_unknown_options(\%options, 'select');
238 4 my %query;
239 $query{'$select'} = _select($options{select})
240 4 ▶ if defined $options{select};
Branch: 1 branch
BranchTrueFalseTotal
if defined $options{"select"} 0 4 4
241 4 my $response = $self->_send(
242 method => 'GET',
243 target => $uri->for_entity($table, $partition_key, $row_key, \%query),
244 headers => { Accept => 'application/json;odata=fullmetadata' },
245 );
246 1 return $serializer->parse_entity($response->body, $response->header('ETag'));
247 }
248
249 3 ▶ method replace_entity ($table, $entity, %options) {
Subroutine replace_entity: called CC=1 SCAR=0.0
Pod undocumented
250 3 return $self->_mutate_entity('PUT', $table, $entity, \%options);
251 }
252
253 2 ▶ method merge_entity ($table, $entity, %options) {
Subroutine merge_entity: called CC=1 SCAR=0.0
Pod undocumented
254 2 return $self->_mutate_entity('MERGE', $table, $entity, \%options);
255 }
256
257 2 ▶ method delete_entity ($table, $partition_key, $row_key, %options) {
Subroutine delete_entity: called CC=2 SCAR=7.1
Pod undocumented
258 2 _reject_unknown_options(\%options, qw(if_exists if_match));
259 2 my $if_match = _if_match($options{if_match});
260 return $self->_send(
261 method => 'DELETE',
262 target => $uri->for_entity($table, $partition_key, $row_key),
263 headers => { 'If-Match' => $if_match },
264 ignored_codes => $options{if_exists}
265 1 ▶ ? [qw(EntityNotFound ResourceNotFound)]
Branch: 1 branch
BranchTrueFalseTotal
$options{'if_exists'} ? : 0 1 1
266 : undef,
267 );
268 }
269
270 5 ▶ method query_entities ($table, %options) {
Subroutine query_entities: called CC=1 SCAR=0.0
Pod undocumented
271 5 my $query = _entity_query(\%options);
272 2 my $response = $self->_send(
273 method => 'GET',
274 target => $uri->for_entities($table, $query),
275 headers => { Accept => 'application/json;odata=fullmetadata' },
276 );
277 2 return $serializer->parse_entity_list(
278 $response->body,
279 $response->header('x-ms-continuation-NextPartitionKey'),
280 $response->header('x-ms-continuation-NextRowKey'),
281 );
282 }
283
284 1 ▶ method query_entities_pager ($table, %options) {
Subroutine query_entities_pager: called CC=3 SCAR=11.4
Pod undocumented
285 1 _reject_unknown_options(
286 \%options,
287 qw(continuation_token filter max_results next_partition_key next_row_key select),
288 );
289 1 _entity_query(\%options);
290
291 1 my $continuation_token = delete $options{continuation_token};
292 1 ▶ if (!defined $continuation_token && defined $options{next_partition_key}) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $continuation_token and defined $options{"next_partition_key"}) 0 1 1
Condition33%1/3
not defined $continuation_token and defined $options{"next_partition_key"}
!ll&&!rl&&r
010
MC/DC0%0/2
not defined $continuation_token and defined $options{"next_partition_key"}
not defined $continuation_token defined $options{"next_partition_key"}
Truth table33%1/3
not(A) and B
A= not defined $continuation_tokenB= defined $options{"next_partition_key"}
ABresult
0X0
100
111
293 $continuation_token = Azure::SDK::Storage::Tables::EntityContinuation->encode(
294 delete $options{next_partition_key},
295 delete $options{next_row_key},
296 0 );
297 }
298 return Azure::SDK::Core::Pager->new(
299 continuation_token => $continuation_token,
300 2 ▶ fetch_page => sub ($token) {
Subroutine __ANON__: called CC=3 SCAR=11.0
301 2 my %page_options = %options;
302 2 ▶ if (defined $token) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $token) 1 1 2
303 1 my ($partition, $row)
304 = Azure::SDK::Storage::Tables::EntityContinuation->decode($token);
305 1 $page_options{next_partition_key} = $partition;
306 1 ▶ $page_options{next_row_key} = $row if defined $row;
Branch: 1 branch
BranchTrueFalseTotal
if defined $row 1 0 1
307 }
308 2 return $self->query_entities($table, %page_options);
309 },
310 1 );
311 }
312
313 0 ▶ method list_all_entities ($table, %options) {
Subroutine list_all_entities: not called CC=2 SCAR=17.9
Pod undocumented
314 0 my $pager = $self->query_entities_pager($table, %options);
315 0 my @items;
316 0 ▶ while (defined(my $item = $pager->next_item)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $item = $pager->next_item)) 0 0 0
317 0 push @items, $item;
318 }
319 0 return \@items;
320 }
321
322 4 ▶ method submit_transaction ($table, $transaction) {
Subroutine submit_transaction: called CC=3 SCAR=11.8
Pod undocumented
323 4 ▶ croak 'Table transaction requires an Azure::SDK::Storage::Tables::Transaction'
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($transaction) and $transaction->isa("Azure::SDK::Storage::Tables::Transaction") 0 4 4
Condition33%1/3
builtin::blessed($transaction) and $transaction->isa("Azure::SDK::Storage::Tables::Transaction")
!ll&&!rl&&r
004
MC/DC0%0/2
builtin::blessed($transaction) and $transaction->isa("Azure::SDK::Storage::Tables::Transaction")
builtin::blessed($transaction) $transaction->isa("Azure::SDK::Storage::Tables::Transaction")
Truth table33%1/3
A and B
A= builtin::blessed($transaction)B= $transaction->isa("Azure::SDK::Storage::Tables::Transaction")
ABresult
0X0
100
111
324 unless blessed($transaction)
325 && $transaction->isa('Azure::SDK::Storage::Tables::Transaction');
326 4 $uri->validate_table_name($table);
327 4 my ($body, $boundary) = $serializer->serialize_transaction(
328 $uri,
329 $table,
330 $transaction,
331 );
332 2 my $response = $self->_send(
333 method => 'POST',
334 target => $uri->for_batch,
335 headers => {
336 'Accept' => 'multipart/mixed',
337 'Content-Length' => length($body),
338 'Content-Type' => "multipart/mixed; boundary=$boundary",
339 },
340 body => $body,
341 );
342 2 return $serializer->parse_transaction_response(
343 $response->body,
344 $response->header('Content-Type'),
345 $transaction->count,
346 );
347 }
348
349 5 ▶ method _mutate_entity ($http_method, $table, $entity, $options) {
Subroutine _mutate_entity: called CC=3 SCAR=11.1
350 5 _reject_unknown_options($options, 'if_match');
351 5 _require_entity($entity);
352 5 ▶ my $if_match = _if_match($options->{if_match} // $entity->etag);
Condition100%3/3
$options->{"if_match"} // $entity->etag
l!l&&r!l&&!r
212
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
ABresult
1X1
011
000
353 2 my $body = $serializer->serialize_entity($entity);
354 2 my $headers = _entity_body_headers($body);
355 2 $headers->{'If-Match'} = $if_match;
356
357 2 my $response = $self->_send(
358 method => $http_method,
359 target => $uri->for_entity(
360 $table,
361 $entity->partition_key,
362 $entity->row_key,
363 ),
364 headers => $headers,
365 body => $body,
366 );
367 2 ▶ return $entity->with_etag($response->header('ETag') // $entity->etag);
Condition33%1/3
$response->header("ETag") // $entity->etag
l!l&&r!l&&!r
200
MC/DC0%0/2
$response->header("ETag") // $entity->etag
$response->header("ETag") $entity->etag
Truth table33%1/3
A // B
A= $response->header("ETag")B= $entity->etag
ABresult
1X1
011
000
368 }
369
370 24 ▶ method _send (%args) {
Subroutine _send: called CC=8 SCAR=20.9
371 my $request = Azure::SDK::Core::Request->new(
372 method => $args{method},
373 url => $args{target}{url},
374 headers => $args{headers} // {},
375 body => $args{body},
376 24 ▶ );
Condition100%2/2
$args{"headers"} // {}
l!l
204
MC/DC100%1/1
$args{"headers"} // {}
$args{"headers"}
Truth table100%2/2
A
A= $args{"headers"}
Aresult
11
00
377
378 24 my $response = eval { $core->send($request) };
379 24 my $error = $@;
380 24 ▶ if ($error) {
Branch: 1 branch
BranchTrueFalseTotal
if ($error) 7 17 24
381 return undef
382 if defined $args{ignored_codes}
383 && blessed($error)
384 && $error->isa('Azure::SDK::Core::Error')
385 && grep {
386 6 ▶ ($error->code // '') eq $_
Condition50%1/2
$error->code // ""
l!l
60
MC/DC0%0/1
$error->code // ""
$error->code
Truth table50%1/2
A
A= $error->code
Aresult
11
00
387 7 ▶ } $args{ignored_codes}->@*;
Branch: 1 branch
BranchTrueFalseTotal
if defined $args{"ignored_codes"} and builtin::blessed($error) and $error->isa("Azure::SDK::Core::Error") and grep {($error->code // "") eq $_;} @{$args{"ignored_codes"}} 2 5 7
Condition77%7/9
defined $args{"ignored_codes"} and builtin::blessed($error) and $error->isa("Azure::SDK::Core::Error") and grep {($error->code // "") eq $_;} @{$args{"ignored_codes"}}
!ll&&!rl&&r
412
defined $args{"ignored_codes"} and builtin::blessed($error) and $error->isa("Azure::SDK::Core::Error")
!ll&&!rl&&r
403
defined $args{"ignored_codes"} and builtin::blessed($error)
!ll&&!rl&&r
403
MC/DC50%2/4
defined $args{"ignored_codes"} and builtin::blessed($error) and $error->isa("Azure::SDK::Core::Error") and grep {($error->code // "") eq $_;} @{$args{"ignored_codes"}}
defined $args{"ignored_codes"} builtin::blessed($error) $error->isa("Azure::SDK::Core::Error") grep {($error->code // "") eq $_;} @{$args{"ignored_codes"}}
Truth table60%3/5
A and B and C and D
A= defined $args{"ignored_codes"}B= builtin::blessed($error)C= $error->isa("Azure::SDK::Core::Error")D= grep {($error->code // "") eq $_;} @{$args{"ignored_codes"}}
ABCDresult
0XXX0
10XX0
110X0
11100
11111
388 5 die $error;
389 }
390 17 return $response;
391 }
392
393 9 ▶ sub _query_value ( $label, $value ) {
Subroutine _query_value: called CC=3 SCAR=11.0
394 9 ▶ croak "$label must be a scalar"
Branch: 1 branch
BranchTrueFalseTotal
if ref $value 1 8 9
395 if ref $value;
396 8 ▶ croak "$label must not contain control characters"
Branch: 1 branch
BranchTrueFalseTotal
if $value =~ /[\x00-\x1f\x7f]/u 1 7 8
397 if $value =~ /[\x00-\x1f\x7f]/;
398 7 return "$value";
399 }
400
401 3 ▶ sub _entity_body_headers ($body) {
Subroutine _entity_body_headers: called CC=1 SCAR=0.0
402 return {
403 3 'Content-Length' => length($body),
404 'Content-Type' => 'application/json',
405 'Prefer' => 'return-no-content',
406 };
407 }
408
409 6 ▶ sub _entity_query ($options) {
Subroutine _entity_query: called CC=14 SCAR=28.7
410 6 _reject_unknown_options(
411 $options,
412 qw(continuation_token filter max_results next_partition_key next_row_key select),
413 );
414 croak 'query_entities continuation_token cannot be combined with continuation key options'
415 if defined $options->{continuation_token}
416 6 ▶ && (defined $options->{next_partition_key} || defined $options->{next_row_key});
Branch: 1 branch
BranchTrueFalseTotal
if defined $options->{"continuation_token"} and defined $options->{"next_partition_key"} || defined $options->{"next_row_key"} 0 6 6
Condition16%1/6
defined $options->{"continuation_token"} and defined $options->{"next_partition_key"} || defined $options->{"next_row_key"}
!ll&&!rl&&r
600
defined $options->{"next_partition_key"} or defined $options->{"next_row_key"}
l!l&&r!l&&!r
000
MC/DC0%0/3
defined $options->{"continuation_token"} and defined $options->{"next_partition_key"} || defined $options->{"next_row_key"}
defined $options->{"continuation_token"} defined $options->{"next_partition_key"} defined $options->{"next_row_key"}
Truth table25%1/4
A and B or C
A= defined $options->{"continuation_token"}B= defined $options->{"next_partition_key"}C= defined $options->{"next_row_key"}
ABCresult
0XX0
1000
11X1
1011
417 croak 'query_entities next_row_key requires next_partition_key'
418 if defined $options->{next_row_key}
419 6 ▶ && !defined $options->{next_partition_key};
Branch: 1 branch
BranchTrueFalseTotal
if defined $options->{"next_row_key"} and not defined $options->{"next_partition_key"} 1 5 6
Condition100%3/3
defined $options->{"next_row_key"} and not defined $options->{"next_partition_key"}
!ll&&!rl&&r
411
MC/DC100%2/2
defined $options->{"next_row_key"} and not defined $options->{"next_partition_key"}
defined $options->{"next_row_key"} not defined $options->{"next_partition_key"}
Truth table100%3/3
A and not(B)
A= defined $options->{"next_row_key"}B= not defined $options->{"next_partition_key"}
ABresult
0X0
100
111
420
421 my ($next_partition_key, $next_row_key)
422 5 = ($options->{next_partition_key}, $options->{next_row_key});
423 5 ▶ if (defined $options->{continuation_token}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $options->{"continuation_token"}) 0 5 5
424 ($next_partition_key, $next_row_key)
425 = Azure::SDK::Storage::Tables::EntityContinuation->decode(
426 $options->{continuation_token},
427 0 );
428 }
429
430 5 my %query;
431 5 ▶ if (defined $options->{filter}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $options->{"filter"}) 3 2 5
432 my $filter = blessed($options->{filter})
433 && $options->{filter}->isa('Azure::SDK::Storage::Tables::Filter')
434 ? $options->{filter}->to_string
435 3 ▶ : _query_value('query_entities filter', $options->{filter});
Branch: 1 branch
BranchTrueFalseTotal
builtin::blessed($options->{'filter'}) && $options->{'filter'}->isa('Azure::SDK::Storage::Tables::Filter') ? : 3 0 3
Condition33%1/3
builtin::blessed($options->{"filter"}) and $options->{"filter"}->isa("Azure::SDK::Storage::Tables::Filter")
!ll&&!rl&&r
003
MC/DC0%0/2
builtin::blessed($options->{"filter"}) and $options->{"filter"}->isa("Azure::SDK::Storage::Tables::Filter")
builtin::blessed($options->{"filter"}) $options->{"filter"}->isa("Azure::SDK::Storage::Tables::Filter")
Truth table33%1/3
A and B
A= builtin::blessed($options->{"filter"})B= $options->{"filter"}->isa("Azure::SDK::Storage::Tables::Filter")
ABresult
0X0
100
111
436 3 $query{'$filter'} = $filter;
437 }
438 $query{'$select'} = _select($options->{select})
439 5 ▶ if defined $options->{select};
Branch: 1 branch
BranchTrueFalseTotal
if defined $options->{"select"} 4 1 5
440 $query{'$top'} = _integer_between(
441 'query_entities max_results',
442 $options->{max_results},
443 1,
444 1000,
445 4 ▶ ) if defined $options->{max_results};
Branch: 1 branch
BranchTrueFalseTotal
if defined $options->{"max_results"} 4 0 4
446 3 ▶ $query{NextPartitionKey} = _query_value(
Branch: 1 branch
BranchTrueFalseTotal
if defined $next_partition_key 1 2 3
447 'query_entities next_partition_key',
448 $next_partition_key,
449 ) if defined $next_partition_key;
450 3 ▶ $query{NextRowKey} = _query_value(
Branch: 1 branch
BranchTrueFalseTotal
if defined $next_row_key 1 2 3
451 'query_entities next_row_key',
452 $next_row_key,
453 ) if defined $next_row_key;
454 3 return \%query;
455 }
456
457 4 ▶ sub _select ($select) {
Subroutine _select: called CC=13 SCAR=29.1
458 4 ▶ croak 'query_entities select must be an array reference'
Branch: 1 branch
BranchTrueFalseTotal
unless ref $select eq "ARRAY" and @$select 0 4 4
Condition33%1/3
ref $select eq "ARRAY" and @$select
!ll&&!rl&&r
004
MC/DC0%0/2
ref $select eq "ARRAY" and @$select
ref $select eq "ARRAY" @$select
Truth table33%1/3
A and B
A= ref $select eq "ARRAY"B= @$select
ABresult
0X0
100
111
459 unless ref $select eq 'ARRAY' && $select->@*;
460 4 my %seen;
461 my @names;
462 4 for my $name ($select->@*) {
463 7 ▶ croak 'query_entities select property is invalid'
Branch: 1 branch
BranchTrueFalseTotal
unless defined $name and not ref $name 0 7 7
Condition33%1/3
defined $name and not ref $name
!ll&&!rl&&r
007
MC/DC0%0/2
defined $name and not ref $name
defined $name not ref $name
Truth table33%1/3
A and not(B)
A= defined $nameB= not ref $name
ABresult
0X0
100
111
464 unless defined $name && !ref $name;
465 7 ▶ if ($name ne 'PartitionKey' && $name ne 'RowKey' && $name ne 'Timestamp') {
Branch: 1 branch
BranchTrueFalseTotal
if ($name ne "PartitionKey" and $name ne "RowKey" and $name ne "Timestamp") 4 3 7
Condition50%3/6
$name ne "PartitionKey" and $name ne "RowKey" and $name ne "Timestamp"
!ll&&!rl&&r
034
$name ne "PartitionKey" and $name ne "RowKey"
!ll&&!rl&&r
007
MC/DC33%1/3
$name ne "PartitionKey" and $name ne "RowKey" and $name ne "Timestamp"
$name ne "PartitionKey" $name ne "RowKey" $name ne "Timestamp"
Truth table50%2/4
A and B and C
A= $name ne "PartitionKey"B= $name ne "RowKey"C= $name ne "Timestamp"
ABCresult
0XX0
10X0
1100
1111
466 4 eval { Azure::SDK::Storage::Tables::Entity->validate_property_name($name) };
467 4 ▶ croak 'query_entities select property is invalid' if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 1 3 4
468 }
469 6 ▶ push @names, $name unless $seen{$name}++;
Branch: 1 branch
BranchTrueFalseTotal
unless $seen{$name}++ 6 0 6
470 }
471 3 ▶ push @names, 'PartitionKey' unless $seen{PartitionKey};
Branch: 1 branch
BranchTrueFalseTotal
unless $seen{"PartitionKey"} 3 0 3
472 3 ▶ push @names, 'RowKey' unless $seen{RowKey};
Branch: 1 branch
BranchTrueFalseTotal
unless $seen{"RowKey"} 3 0 3
473 3 return join ',', @names;
474 }
475
476 7 ▶ sub _if_match ($value) {
Subroutine _if_match: called CC=5 SCAR=16.3
477 7 ▶ croak 'Table entity if_match is required; use "*" for an unconditional mutation'
Branch: 1 branch
BranchTrueFalseTotal
unless defined $value and not ref $value and length $value 3 4 7
Condition66%4/6
defined $value and not ref $value and length $value
!ll&&!rl&&r
304
defined $value and not ref $value
!ll&&!rl&&r
304
MC/DC33%1/3
defined $value and not ref $value and length $value
defined $value not ref $value length $value
Truth table50%2/4
A and not(B) and C
A= defined $valueB= not ref $valueC= length $value
ABCresult
0XX0
10X0
1100
1111
478 unless defined $value && !ref $value && length $value;
479 4 ▶ croak 'Table entity if_match must not contain control characters'
Branch: 1 branch
BranchTrueFalseTotal
if $value =~ /[\x00-\x1f\x7f]/u 1 3 4
480 if $value =~ /[\x00-\x1f\x7f]/;
481 3 return $value;
482 }
483
484 7 ▶ sub _require_entity ($entity) {
Subroutine _require_entity: called CC=3 SCAR=11.1
485 7 ▶ croak 'Table entity operation requires an Azure::SDK::Storage::Tables::Entity'
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($entity) and $entity->isa("Azure::SDK::Storage::Tables::Entity") 1 6 7
Condition66%2/3
builtin::blessed($entity) and $entity->isa("Azure::SDK::Storage::Tables::Entity")
!ll&&!rl&&r
106
MC/DC50%1/2
builtin::blessed($entity) and $entity->isa("Azure::SDK::Storage::Tables::Entity")
builtin::blessed($entity) $entity->isa("Azure::SDK::Storage::Tables::Entity")
Truth table66%2/3
A and B
A= builtin::blessed($entity)B= $entity->isa("Azure::SDK::Storage::Tables::Entity")
ABresult
0X0
100
111
486 unless blessed($entity)
487 && $entity->isa('Azure::SDK::Storage::Tables::Entity');
488 6 return $entity;
489 }
490
491 10 ▶ sub _integer_between ( $label, $value, $minimum, $maximum ) {
Subroutine _integer_between: called CC=6 SCAR=19.6
492 10 ▶ croak "$label must be between $minimum and $maximum"
Branch: 1 branch
BranchTrueFalseTotal
unless defined $value and not ref $value and $value =~ /\A[0-9]+\z/u and $value >= $minimum and $value <= $maximum 3 7 10
Condition58%7/12
defined $value and not ref $value and $value =~ /\A[0-9]+\z/u and $value >= $minimum and $value <= $maximum
!ll&&!rl&&r
127
defined $value and not ref $value and $value =~ /\A[0-9]+\z/u and $value >= $minimum
!ll&&!rl&&r
019
defined $value and not ref $value and $value =~ /\A[0-9]+\z/u
!ll&&!rl&&r
0010
defined $value and not ref $value
!ll&&!rl&&r
0010
MC/DC40%2/5
defined $value and not ref $value and $value =~ /\A[0-9]+\z/u and $value >= $minimum and $value <= $maximum
defined $value not ref $value $value =~ /\A[0-9]+\z/u $value >= $minimum $value <= $maximum
Truth table50%3/6
A and not(B) and C and D and E
A= defined $valueB= not ref $valueC= $value =~ /\A[0-9]+\z/uD= $value >= $minimumE= $value <= $maximum
ABCDEresult
0XXXX0
10XXX0
110XX0
1110X0
111100
111111
493 unless defined $value
494 && !ref $value
495 && $value =~ /\A[0-9]+\z/
496 && $value >= $minimum
497 && $value <= $maximum;
498 7 return 0 + $value;
499 }
500
501 41 ▶ sub _reject_unknown_options ( $options, @allowed ) {
Subroutine _reject_unknown_options: called CC=2 SCAR=6.9
502 41 my %allowed = map { $_ => 1 } @allowed;
503 41 my @unknown = sort grep { !$allowed{$_} } keys %{$options};
504 41 ▶ croak 'Unknown Table operation option(s): ' . join(', ', @unknown)
Branch: 1 branch
BranchTrueFalseTotal
if @unknown 2 39 41
505 if @unknown;
506 }
507 }
508
509 4 1;
510
511 __END__
« SDK/Storage/Blobs.pm ↑ Summary SDK/Core/Transport/Default.pm »