line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Geoffrey::Action::Constraint::PrimaryKey; |
2
|
|
|
|
|
|
|
|
3
|
6
|
|
|
6
|
|
21351
|
use utf8; |
|
6
|
|
|
|
|
26
|
|
|
6
|
|
|
|
|
36
|
|
4
|
6
|
|
|
6
|
|
245
|
use 5.016; |
|
6
|
|
|
|
|
20
|
|
5
|
6
|
|
|
6
|
|
31
|
use strict; |
|
6
|
|
|
|
|
11
|
|
|
6
|
|
|
|
|
117
|
|
6
|
6
|
|
|
6
|
|
29
|
use warnings; |
|
6
|
|
|
|
|
22
|
|
|
6
|
|
|
|
|
211
|
|
7
|
6
|
|
|
6
|
|
3321
|
use Time::HiRes qw/ time /; |
|
6
|
|
|
|
|
8834
|
|
|
6
|
|
|
|
|
27
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
$Geoffrey::Action::Constraint::PrimaryKey::VERSION = '0.000203'; |
10
|
|
|
|
|
|
|
|
11
|
6
|
|
|
6
|
|
1720
|
use parent 'Geoffrey::Role::Action'; |
|
6
|
|
|
|
|
331
|
|
|
6
|
|
|
|
|
36
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub add { |
14
|
2
|
|
|
2
|
1
|
1660
|
my ( $self, $s_table_name, $hr_params ) = @_; |
15
|
2
|
50
|
|
|
|
10
|
if ( !$self->converter->primary_key ) { |
16
|
0
|
|
|
|
|
0
|
require Geoffrey::Exception::NotSupportedException; |
17
|
0
|
|
|
|
|
0
|
Geoffrey::Exception::NotSupportedException::throw_primarykey( 'add', $self->converter ); |
18
|
|
|
|
|
|
|
} |
19
|
2
|
|
|
|
|
10
|
my $gentime = time; |
20
|
2
|
|
|
|
|
30
|
$gentime =~ s/\.//g; |
21
|
2
|
|
33
|
|
|
11
|
$hr_params->{name} ||= q~pk_~ . $s_table_name . q~_~ . $gentime; |
22
|
2
|
|
|
|
|
11
|
require Geoffrey::Utils; |
23
|
|
|
|
|
|
|
return Geoffrey::Utils::replace_spare( $self->converter->primary_key->add, |
24
|
2
|
|
|
|
|
7
|
[ $hr_params->{name}, ( join q/,/, @{ $hr_params->{columns} } ) ] ); |
|
2
|
|
|
|
|
12
|
|
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub alter { |
28
|
1
|
|
|
1
|
1
|
1622
|
my ( $self, $s_table_name, $hr_params ) = @_; |
29
|
1
|
50
|
|
|
|
9
|
if ( !$self->converter->primary_key ) { |
30
|
0
|
|
|
|
|
0
|
require Geoffrey::Exception::NotSupportedException; |
31
|
0
|
|
|
|
|
0
|
Geoffrey::Exception::NotSupportedException::throw_primarykey( 'alter', $self->converter ); |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
return [ |
34
|
1
|
|
|
|
|
5
|
$self->drop( $s_table_name, $hr_params ), |
35
|
|
|
|
|
|
|
$self->add( $s_table_name, $hr_params ), |
36
|
|
|
|
|
|
|
]; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub drop { |
40
|
2
|
|
|
2
|
1
|
2169
|
my ( $self, $table, $name, $schema ) = @_; |
41
|
2
|
50
|
|
|
|
6
|
if ( !$self->converter->primary_key ) { |
42
|
0
|
|
|
|
|
0
|
require Geoffrey::Exception::NotSupportedException; |
43
|
0
|
|
|
|
|
0
|
Geoffrey::Exception::NotSupportedException::throw_primarykey( 'drop', $self->converter ); |
44
|
|
|
|
|
|
|
} |
45
|
2
|
|
|
|
|
513
|
require Geoffrey::Utils; |
46
|
2
|
|
|
|
|
8
|
return Geoffrey::Utils::replace_spare( $self->converter->primary_key->drop($schema), |
47
|
|
|
|
|
|
|
[ $table, $name ] ); |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub list_from_schema { |
51
|
3
|
|
|
3
|
1
|
1747
|
my ( $self, $schema ) = @_; |
52
|
3
|
50
|
|
|
|
17
|
if ( !$self->converter->primary_key ) { |
53
|
0
|
|
|
|
|
0
|
require Geoffrey::Exception::NotSupportedException; |
54
|
0
|
|
|
|
|
0
|
Geoffrey::Exception::NotSupportedException::throw_primarykey( 'list', $self->converter ); |
55
|
|
|
|
|
|
|
} |
56
|
3
|
|
|
|
|
14
|
return $self->converter->primary_key_information( |
57
|
|
|
|
|
|
|
$self->do_arrayref( $self->converter->primary_key->list($schema), [] ), |
58
|
|
|
|
|
|
|
); |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
1; |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
__END__ |