| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Geoffrey::Action::Constraint::Unique; |
|
2
|
|
|
|
|
|
|
|
|
3
|
6
|
|
|
6
|
|
30237
|
use utf8; |
|
|
6
|
|
|
|
|
47
|
|
|
|
6
|
|
|
|
|
43
|
|
|
4
|
6
|
|
|
6
|
|
237
|
use 5.016; |
|
|
6
|
|
|
|
|
20
|
|
|
5
|
6
|
|
|
6
|
|
30
|
use strict; |
|
|
6
|
|
|
|
|
11
|
|
|
|
6
|
|
|
|
|
272
|
|
|
6
|
6
|
|
|
6
|
|
41
|
use warnings; |
|
|
6
|
|
|
|
|
11
|
|
|
|
6
|
|
|
|
|
158
|
|
|
7
|
6
|
|
|
6
|
|
2549
|
use Ref::Util; |
|
|
6
|
|
|
|
|
8381
|
|
|
|
6
|
|
|
|
|
336
|
|
|
8
|
6
|
|
|
6
|
|
565
|
use Time::HiRes qw/ time /; |
|
|
6
|
|
|
|
|
1407
|
|
|
|
6
|
|
|
|
|
39
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
$Geoffrey::Action::Constraint::Unique::VERSION = '0.000204'; |
|
11
|
|
|
|
|
|
|
|
|
12
|
6
|
|
|
6
|
|
825
|
use parent 'Geoffrey::Role::Action'; |
|
|
6
|
|
|
|
|
13
|
|
|
|
6
|
|
|
|
|
36
|
|
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub add { |
|
15
|
11
|
|
|
11
|
1
|
7854
|
my ( $self, $s_table_name, $hr_params ) = @_; |
|
16
|
11
|
|
|
|
|
36
|
my $unique = $self->converter->unique; |
|
17
|
11
|
50
|
|
|
|
32
|
if ( !$unique ) { |
|
18
|
0
|
|
|
|
|
0
|
require Geoffrey::Exception::NotSupportedException; |
|
19
|
0
|
|
|
|
|
0
|
Geoffrey::Exception::NotSupportedException::throw_unique( 'add', $self->converter ); |
|
20
|
|
|
|
|
|
|
} |
|
21
|
11
|
100
|
|
|
|
22
|
if ( !$s_table_name ) { |
|
22
|
2
|
|
|
|
|
536
|
require Geoffrey::Exception::RequiredValue; |
|
23
|
2
|
|
|
|
|
10
|
Geoffrey::Exception::RequiredValue::throw_table_name( __PACKAGE__ . '::add' ); |
|
24
|
|
|
|
|
|
|
} |
|
25
|
9
|
50
|
|
|
|
33
|
return () unless $hr_params; |
|
26
|
9
|
100
|
|
|
|
26
|
if ( !Ref::Util::is_hashref($hr_params) ) { |
|
27
|
2
|
|
|
|
|
527
|
require Geoffrey::Exception::General; |
|
28
|
2
|
|
|
|
|
8
|
Geoffrey::Exception::General::throw_wrong_ref( __PACKAGE__ . '::add', 'hash' ); |
|
29
|
|
|
|
|
|
|
} |
|
30
|
7
|
100
|
66
|
|
|
23
|
if ( !$hr_params->{columns} || scalar @{ $hr_params->{columns} } == 0 ) { |
|
|
5
|
|
|
|
|
23
|
|
|
31
|
2
|
|
|
|
|
14
|
require Geoffrey::Exception::RequiredValue; |
|
32
|
2
|
|
|
|
|
8
|
Geoffrey::Exception::RequiredValue::throw_table_column( __PACKAGE__ . '::add' ); |
|
33
|
|
|
|
|
|
|
} |
|
34
|
|
|
|
|
|
|
|
|
35
|
5
|
|
|
|
|
15
|
$s_table_name =~ s/"//g; |
|
36
|
5
|
|
|
|
|
17
|
my $gentime = time; |
|
37
|
5
|
|
|
|
|
60
|
$gentime =~ s/\.//g; |
|
38
|
5
|
|
33
|
|
|
17
|
$hr_params->{name} ||= 'uidx_' . $s_table_name . '_' . $gentime; |
|
39
|
|
|
|
|
|
|
|
|
40
|
5
|
|
|
|
|
511
|
require Geoffrey::Utils; |
|
41
|
|
|
|
|
|
|
return Geoffrey::Utils::replace_spare( $unique->add, |
|
42
|
5
|
100
|
|
|
|
19
|
[ $hr_params->{name}, join q/,/, @{ $hr_params->{columns} } ] ) |
|
|
2
|
|
|
|
|
10
|
|
|
43
|
|
|
|
|
|
|
if $self->for_table; |
|
44
|
|
|
|
|
|
|
return $self->do( |
|
45
|
|
|
|
|
|
|
Geoffrey::Utils::replace_spare( |
|
46
|
|
|
|
|
|
|
$unique->append, |
|
47
|
3
|
|
|
|
|
12
|
[ $hr_params->{name}, $s_table_name, join q/,/, @{ $hr_params->{columns} } ] |
|
|
3
|
|
|
|
|
16
|
|
|
48
|
|
|
|
|
|
|
) |
|
49
|
|
|
|
|
|
|
); |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
} |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub alter { |
|
54
|
1
|
|
|
1
|
1
|
42
|
my ( $self, $s_table_name, $hr_column_params ) = @_; |
|
55
|
1
|
|
|
|
|
5
|
my $unique = $self->converter->unique; |
|
56
|
1
|
50
|
|
|
|
4
|
if ( !$unique ) { |
|
57
|
0
|
|
|
|
|
0
|
require Geoffrey::Exception::NotSupportedException; |
|
58
|
0
|
|
|
|
|
0
|
Geoffrey::Exception::NotSupportedException::throw_unique( 'alter', $self->converter ); |
|
59
|
|
|
|
|
|
|
} |
|
60
|
|
|
|
|
|
|
return [ |
|
61
|
1
|
|
|
|
|
6
|
$self->drop( $s_table_name, $hr_column_params ), |
|
62
|
|
|
|
|
|
|
$self->append( $s_table_name, $hr_column_params ), |
|
63
|
|
|
|
|
|
|
]; |
|
64
|
|
|
|
|
|
|
} |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub drop { |
|
67
|
2
|
|
|
2
|
1
|
5
|
my ( $self, $s_table_name, $hr_column_params ) = @_; |
|
68
|
2
|
|
|
|
|
10
|
my $unique = $self->converter->unique; |
|
69
|
2
|
50
|
|
|
|
7
|
if ( !$unique ) { |
|
70
|
0
|
|
|
|
|
0
|
require Geoffrey::Exception::NotSupportedException; |
|
71
|
0
|
|
|
|
|
0
|
Geoffrey::Exception::NotSupportedException::throw_unique( 'drop', $self->converter ); |
|
72
|
|
|
|
|
|
|
} |
|
73
|
2
|
100
|
|
|
|
10
|
if ( !$s_table_name ) { |
|
74
|
1
|
|
|
|
|
9
|
require Geoffrey::Exception::RequiredValue; |
|
75
|
1
|
|
|
|
|
6
|
Geoffrey::Exception::RequiredValue::throw_table_name( __PACKAGE__ . '::drop' ); |
|
76
|
|
|
|
|
|
|
} |
|
77
|
1
|
|
|
|
|
19
|
require Geoffrey::Utils; |
|
78
|
|
|
|
|
|
|
return Geoffrey::Utils::replace_spare( $unique->drop, |
|
79
|
1
|
|
|
|
|
31
|
[ $s_table_name, $hr_column_params->{name}, ] ); |
|
80
|
|
|
|
|
|
|
} |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
sub list_from_schema { |
|
83
|
4
|
|
|
4
|
1
|
12
|
my ( $self, $schema ) = @_; |
|
84
|
4
|
|
|
|
|
22
|
my $unique = $self->converter->unique; |
|
85
|
4
|
50
|
|
|
|
15
|
if ( !$unique ) { |
|
86
|
0
|
|
|
|
|
0
|
require Geoffrey::Exception::NotSupportedException; |
|
87
|
0
|
|
|
|
|
0
|
Geoffrey::Exception::NotSupportedException::throw_unique( 'list', $self->converter ); |
|
88
|
|
|
|
|
|
|
} |
|
89
|
4
|
|
|
|
|
16
|
return $self->converter->unique_information( $self->do_arrayref( $unique->list($schema) ) ); |
|
90
|
|
|
|
|
|
|
} |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
1; |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
__END__ |