line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MySQL::Util::Lite::Column; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
6
|
use Modern::Perl; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
5
|
|
6
|
1
|
|
|
1
|
|
95
|
use Moose; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
8
|
|
7
|
1
|
|
|
1
|
|
5198
|
use namespace::autoclean; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
5
|
|
8
|
1
|
|
|
1
|
|
49
|
use Method::Signatures; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
4
|
|
9
|
1
|
|
|
1
|
|
315
|
use Data::Printer alias => 'pdump'; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
7
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
has name => ( |
12
|
|
|
|
|
|
|
is => 'ro', |
13
|
|
|
|
|
|
|
isa => 'Str', |
14
|
|
|
|
|
|
|
required => 1, |
15
|
|
|
|
|
|
|
); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
has key => ( |
18
|
|
|
|
|
|
|
is => 'ro', |
19
|
|
|
|
|
|
|
isa => 'Str|Undef', |
20
|
|
|
|
|
|
|
); |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
has default => ( |
23
|
|
|
|
|
|
|
is => 'ro', |
24
|
|
|
|
|
|
|
isa => 'Str|Undef', |
25
|
|
|
|
|
|
|
); |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
has type => ( |
28
|
|
|
|
|
|
|
is => 'ro', |
29
|
|
|
|
|
|
|
isa => 'Str', |
30
|
|
|
|
|
|
|
required => 1, |
31
|
|
|
|
|
|
|
); |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
has is_null => ( |
34
|
|
|
|
|
|
|
is => 'rw', |
35
|
|
|
|
|
|
|
isa => 'Bool', |
36
|
|
|
|
|
|
|
required => 1, |
37
|
|
|
|
|
|
|
); |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
has is_autoinc => ( |
40
|
|
|
|
|
|
|
is => 'rw', |
41
|
|
|
|
|
|
|
isa => 'Bool', |
42
|
|
|
|
|
|
|
default => 0, |
43
|
|
|
|
|
|
|
); |
44
|
|
|
|
|
|
|
|
45
|
1
|
0
|
|
1
|
|
1887
|
method get_moose_type { |
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
|
47
|
0
|
|
|
|
|
|
my $str; |
48
|
0
|
|
|
|
|
|
my $type = $self->type; |
49
|
|
|
|
|
|
|
|
50
|
0
|
0
|
0
|
|
|
|
if ( $type =~ /varchar/i ) { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
51
|
0
|
|
|
|
|
|
$str = 'Str|HashRef'; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
elsif ( $type =~ /timestamp/i || $type =~ /datetime/i) { |
54
|
0
|
|
|
|
|
|
$str = 'Str|HashRef'; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
elsif ( $type =~ /enum/i ) { |
57
|
0
|
|
|
|
|
|
$str = 'Str|HashRef'; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
else { |
60
|
0
|
|
|
|
|
|
$str = 'Num|HashRef'; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
0
|
0
|
|
|
|
|
if ( $self->is_null ) { |
64
|
0
|
|
|
|
|
|
$str .= '|Undef'; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
0
|
|
|
|
|
|
return $str; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
1
|
0
|
|
1
|
|
762
|
method get_ddl { |
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
|
|
|
|
71
|
0
|
|
|
|
|
|
my $sql = "`" . $self->name . "` " . $self->type . ' '; |
72
|
|
|
|
|
|
|
|
73
|
0
|
0
|
|
|
|
|
if( $self->is_null ){ |
74
|
0
|
|
|
|
|
|
$sql .= " NULL "; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
else{ |
77
|
0
|
|
|
|
|
|
$sql .= " NOT NULL "; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
0
|
|
|
|
|
|
my $default = $self->default; |
81
|
0
|
0
|
0
|
|
|
|
if( defined $default && $self->type =~ /varchar/i ){ |
82
|
0
|
|
|
|
|
|
$default = "\"$default\""; # Surround default in quotes |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
0
|
0
|
|
|
|
|
if( $self->is_null ){ |
86
|
0
|
0
|
|
|
|
|
if( defined $self->default){ |
87
|
0
|
0
|
|
|
|
|
$sql .= " DEFAULT $default" if defined $self->default; |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
else{ |
90
|
0
|
|
|
|
|
|
$sql .= " DEFAULT NULL "; |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
else{ |
94
|
0
|
0
|
|
|
|
|
$sql .= "DEFAULT $default" if defined $self->default; |
95
|
|
|
|
|
|
|
} |
96
|
0
|
0
|
|
|
|
|
$sql .= "AUTO_INCREMENT " if $self->is_autoinc; |
97
|
|
|
|
|
|
|
|
98
|
0
|
|
|
|
|
|
return $sql; |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
1; |