« blib/lib/SQL/Translator/Producer/XML/SQLFairy.pm
↑ Summary
blib/lib/SQL/Translator/Producer/Dumper.pm »
| 1 | package SQL::Translator::Schema::Index; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | =pod | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | SQL::Translator::Schema::Index - SQL::Translator index object | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | use SQL::Translator::Schema::Index; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | my $index = SQL::Translator::Schema::Index->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | name => 'foo', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | fields => [ id ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | type => 'unique', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | C<SQL::Translator::Schema::Index> is the index object. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | Primary and unique keys are table constraints, not indices. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | =head1 METHODS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 73 | ▶ | use Moo; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 73 | ▶ | use SQL::Translator::Schema::Constants; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 73 | ▶ | use SQL::Translator::Utils qw(ex2err throw); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 73 | ▶ | use SQL::Translator::Role::ListAttr; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 73 | ▶ | use SQL::Translator::Types qw(schema_obj enum); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 73 | ▶ | use Sub::Quote qw(quote_sub); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 73 | extends 'SQL::Translator::Schema::Object'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 73 | our $VERSION = '1.6_3'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 73 | my %VALID_INDEX_TYPE = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | UNIQUE => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | NORMAL => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | FULLTEXT => 1, # MySQL only (?) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | FULL_TEXT => 1, # MySQL only (?) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | SPATIAL => 1, # MySQL only (?) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | =head2 new | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | Object constructor. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | my $schema = SQL::Translator::Schema::Index->new; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | =head2 fields | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | Gets and set the fields the index is on. Accepts a string, list or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | arrayref; returns an array or array reference. Will unique the field | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | names and keep them in order by the first occurrence of a field name. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | $index->fields('id'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | $index->fields('id', 'name'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | $index->fields( 'id, name' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | $index->fields( [ 'id', 'name' ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | $index->fields( qw[ id name ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | my @fields = $index->fields; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 73 | with ListAttr fields => ( uniq => 1 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | sub is_valid { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | =pod | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | =head2 is_valid | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | Determine whether the index is valid or not. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | my $ok = $index->is_valid; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 20 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_valid: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 20 | ▶ | my $table = $self->table or return $self->error('No table'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 20 | ▶ | my @fields = $self->fields or return $self->error('No fields'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 19 | for my $field ( @fields ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 23 | ▶ | return $self->error( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | "Field '$field' does not exist in table '", $table->name, "'" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | ) unless $table->get_field( $field ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 17 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | =head2 name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | Get or set the index's name. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | my $name = $index->name('foo'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 73 | has name => ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | coerce => quote_sub(q{ defined $_[0] ? $_[0] : '' }), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | default => quote_sub(q{ '' }), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | =head2 options | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | Get or set the index's options (e.g., "using" or "where" for PG). Returns | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | an array or array reference. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | my @options = $index->options; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 73 | with ListAttr options => (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | =head2 table | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | Get or set the index's table object. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | my $table = $index->table; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 73 | has table => ( is => 'rw', isa => schema_obj('Table'), weak_ref => 1 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 73 | around table => \&ex2err; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | =head2 type | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | Get or set the index's type. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | my $type = $index->type('unique'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | Get or set the index's type. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | Currently there are only four acceptable types: UNIQUE, NORMAL, FULL_TEXT, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | and SPATIAL. The latter two might be MySQL-specific. While both lowercase | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | and uppercase types are acceptable input, this method returns the type in | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | uppercase. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 73 | has type => ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | coerce => quote_sub(q{ uc $_[0] }), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | default => quote_sub(q{ 'NORMAL' }), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | isa => enum([keys %VALID_INDEX_TYPE], { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | msg => "Invalid index type: %s", allow_false => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | }), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 73 | around type => \&ex2err; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | =head2 equals | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | Determines if this index is the same as another | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | my $isIdentical = $index1->equals( $index2 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | around equals => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 93 | ▶ | my $orig = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=18 SCAR=30.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 93 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 93 | my $other = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 93 | my $case_insensitive = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 93 | my $ignore_index_names = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 93 | ▶ | return 0 unless $self->$orig($other); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 93 | ▶ | unless ($ignore_index_names) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 85 | ▶ | unless ((!$self->name && ($other->name eq $other->fields->[0])) || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition55%5/9
not $self->name and $other->name eq $other->fields->[0] or not $other->name and $self->name eq $self->fields->[0]
not $self->name and $other->name eq $other->fields->[0]
not $other->name and $self->name eq $self->fields->[0]
MC/DC0%0/4
not $self->name and $other->name eq $other->fields->[0] or not $other->name and $self->name eq $self->fields->[0]
not $self->name
$other->name eq $other->fields->[0]
not $other->name
$self->name eq $self->fields->[0]
Truth table28%2/7
not(A) and B or not(C) and D
A= not $self->nameB= $other->name eq $other->fields->[0]C= not $other->nameD= $self->name eq $self->fields->[0]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | (!$other->name && ($self->name eq $self->fields->[0]))) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 85 | ▶ | return 0 unless $case_insensitive ? uc($self->name) eq uc($other->name) : $self->name eq $other->name; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | #return 0 unless $self->is_valid eq $other->is_valid; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 27 | ▶ | return 0 unless $self->type eq $other->type; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | # Check fields, regardless of order | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 27 | my %otherFields = (); # create a hash of the other fields | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 27 | foreach my $otherField ($other->fields) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 35 | ▶ | $otherField = uc($otherField) if $case_insensitive; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 35 | $otherFields{$otherField} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 27 | foreach my $selfField ($self->fields) { # check for self fields in hash | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 28 | ▶ | $selfField = uc($selfField) if $case_insensitive; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 28 | ▶ | return 0 unless $otherFields{$selfField}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 18 | delete $otherFields{$selfField}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | # Check all other fields were accounted for | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 17 | ▶ | return 0 unless keys %otherFields == 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 15 | ▶ | return 0 unless $self->_compare_objects(scalar $self->options, scalar $other->options); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 14 | ▶ | return 0 unless $self->_compare_objects(scalar $self->extra, scalar $other->extra); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 14 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 73 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | # Must come after all 'has' declarations | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 73 | around new => \&ex2err; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 73 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | =pod | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | =head1 AUTHOR | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | Ken Youens-Clark E<lt>kclark@cpan.orgE<gt>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||