Oracle/Diff/Index.pm

filter: Statementstmt 41.1% 14 / 34 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 44.4% 4 / 9 Podpod 100% 3 / 3 totaltotal 38.1% 21 / 55 CC 5 SCAR 25.2
CC
5
Cov
33%
as_sql
30.0
diff
2.0
__ANON__
2.0
CRAP 12.5
« Oracle/Storage/ConnectSetup.pm ↑ Summary Oracle/Diff/Table.pm »
1 package DBIO::Oracle::Diff::Index;
2 # ABSTRACT: Diff operations for Oracle indexes
3  
4 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 2 ▶use base 'DBIO::Diff::Op';
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 2 ▶use DBIO::SQL::Util qw(_quote_ident);
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 2 __PACKAGE__->mk_diff_accessors(qw(index_name table_name index_info));
12  
13  
14  
15 0 ▶sub diff {
Subroutine diff: not called CC=1 SCAR=6.9
Pod documented
16 0 my ($class, $source, $target) = @_;
17 return $class->diff_nested(
18 $source, $target,
19 scope => 'both',
20 0 ▶ on_new => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
21 0 my ($tbl, $idx_name, $idx) = @_;
22 0 $class->new(
23 action => 'create',
24 index_name => $idx_name,
25 table_name => $tbl,
26 index_info => $idx,
27 );
28 },
29 0 ▶ on_gone => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
30 0 my ($tbl, $idx_name, $idx) = @_;
31 0 $class->new(
32 action => 'drop',
33 index_name => $idx_name,
34 table_name => $tbl,
35 index_info => $idx,
36 );
37 },
38 0 );
39 }
40  
41  
42 0 ▶sub as_sql {
Subroutine as_sql: not called CC=5 SCAR=34.0
Pod documented
43 0 my ($self) = @_;
44  
45 0 my $idx = _quote_ident($self->index_name);
46 0 my $tbl = _quote_ident($self->table_name);
47 0 my $info = $self->index_info;
48 0 ▶ my $cols = join(', ', map { _quote_ident($_) } @{ $info->{columns} // [] });
Condition0%0/2
$info->{"columns"} // []
l!l
00
MC/DC0%0/1
$info->{"columns"} // []
$info->{"columns"}
Truth table0%0/2
A
A= $info->{"columns"}
Aresult
11
00
49  
50 0 ▶ if ($self->action eq 'create') {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->action eq "create") 0 0 0
51 0 ▶ my $unique = $info->{is_unique} ? 'UNIQUE ' : '';
Branch: 1 branch
BranchTrueFalseTotal
$info->{'is_unique'} ? : 0 0 0
52 0 return sprintf 'CREATE %sINDEX %s ON %s (%s);',
53 $unique, $idx, $tbl, $cols;
54 }
55  
56 0 ▶ if ($self->action eq 'drop') {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->action eq "drop") 0 0 0
57 0 return sprintf 'DROP INDEX %s;', $idx;
58 }
59 }
60  
61  
62 0 ▶sub summary {
Subroutine summary: not called CC=1 SCAR=6.9
Pod documented
63 0 my ($self) = @_;
64 0 return sprintf ' %sindex: %s on %s',
65 $self->summary_prefix, $self->index_name, $self->table_name;
66 }
67  
68 2 1;
69  
70 __END__
71  
72 =pod
73  
74 =encoding UTF-8
75  
76 =head1 NAME
77  
78 DBIO::Oracle::Diff::Index - Diff operations for Oracle indexes
79  
80 =head1 VERSION
81  
82 version 0.900001
83  
84 =head1 DESCRIPTION
85  
86 Index-level diff operations for Oracle.
87  
88 =head1 ATTRIBUTES
89  
90 =head2 index_name
91  
92 The bare index name.
93  
94 =head2 table_name
95  
96 The bare table name the index belongs to.
97  
98 =head2 index_info
99  
100 Hashref of index metadata: C<is_unique>, C<columns>.
101  
102 =head1 METHODS
103  
104 =head2 diff
105  
106 my @ops = DBIO::Oracle::Diff::Index->diff($source, $target);
107  
108 Walks tables present in B<both> C<$source> and C<$target> (C<scope = both>).
109 Source-only tables have their indexes cascaded by the table drop, so they
110 are not walked here; brand-new tables inline their indexes in the CREATE
111 TABLE statement emitted by L<DBIO::Oracle::Diff::Table>, so target-only
112 tables are skipped too.
113  
114 =head2 as_sql
115  
116 =head2 summary
117  
118 =head1 AUTHOR
119  
120 DBIO & DBIx::Class Authors
121  
122 =head1 COPYRIGHT AND LICENSE
123  
124 Copyright (C) 2026 DBIO Authors
125 Portions Copyright (C) 2005-2025 DBIx::Class Authors
126 Based on DBIx::Class, heavily modified.
127  
128 This is free software; you can redistribute it and/or modify it under
129 the same terms as the Perl 5 programming language system itself.
130  
131 =cut
« Oracle/Storage/ConnectSetup.pm ↑ Summary Oracle/Diff/Table.pm »