line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Geoffrey::Action::Constraint::PrimaryKey; |
2
|
|
|
|
|
|
|
|
3
|
6
|
|
|
6
|
|
22149
|
use utf8; |
|
6
|
|
|
|
|
28
|
|
|
6
|
|
|
|
|
36
|
|
4
|
6
|
|
|
6
|
|
250
|
use 5.016; |
|
6
|
|
|
|
|
23
|
|
5
|
6
|
|
|
6
|
|
30
|
use strict; |
|
6
|
|
|
|
|
14
|
|
|
6
|
|
|
|
|
126
|
|
6
|
6
|
|
|
6
|
|
29
|
use warnings; |
|
6
|
|
|
|
|
16
|
|
|
6
|
|
|
|
|
212
|
|
7
|
6
|
|
|
6
|
|
3338
|
use Time::HiRes qw/ time /; |
|
6
|
|
|
|
|
8712
|
|
|
6
|
|
|
|
|
25
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
$Geoffrey::Action::Constraint::PrimaryKey::VERSION = '0.000204'; |
10
|
|
|
|
|
|
|
|
11
|
6
|
|
|
6
|
|
1830
|
use parent 'Geoffrey::Role::Action'; |
|
6
|
|
|
|
|
332
|
|
|
6
|
|
|
|
|
39
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub add { |
14
|
2
|
|
|
2
|
1
|
1721
|
my ( $self, $s_table_name, $hr_params ) = @_; |
15
|
2
|
50
|
|
|
|
12
|
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
|
|
|
|
|
35
|
$gentime =~ s/\.//g; |
21
|
2
|
|
33
|
|
|
13
|
$hr_params->{name} ||= q~pk_~ . $s_table_name . q~_~ . $gentime; |
22
|
2
|
|
|
|
|
15
|
require Geoffrey::Utils; |
23
|
|
|
|
|
|
|
return Geoffrey::Utils::replace_spare( $self->converter->primary_key->add, |
24
|
2
|
|
|
|
|
10
|
[ $hr_params->{name}, ( join q/,/, @{ $hr_params->{columns} } ) ] ); |
|
2
|
|
|
|
|
12
|
|
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub alter { |
28
|
1
|
|
|
1
|
1
|
1385
|
my ( $self, $s_table_name, $hr_params ) = @_; |
29
|
1
|
50
|
|
|
|
19
|
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
|
2293
|
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
|
|
|
|
|
559
|
require Geoffrey::Utils; |
46
|
2
|
|
|
|
|
9
|
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
|
1781
|
my ( $self, $schema ) = @_; |
52
|
3
|
50
|
|
|
|
16
|
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
|
|
|
|
|
13
|
return $self->converter->primary_key_information( |
57
|
|
|
|
|
|
|
$self->do_arrayref( $self->converter->primary_key->list($schema), [] ), |
58
|
|
|
|
|
|
|
); |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
1; |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
__END__ |