line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package SQL::Translator::Generator::DDL::SQLite; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=head1 NAME |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
SQL::Translator::Generator::DDL::SQLite - A Moo based SQLite DDL generation |
6
|
|
|
|
|
|
|
engine. |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 DESCRIPTION |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
I |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=cut |
13
|
|
|
|
|
|
|
|
14
|
9
|
|
|
9
|
|
53
|
use Moo; |
|
9
|
|
|
|
|
21
|
|
|
9
|
|
|
|
|
66
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
has quote_chars => (is=>'ro', default=>sub { +[qw(" ")] } ); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
with 'SQL::Translator::Generator::Role::Quote'; |
19
|
|
|
|
|
|
|
with 'SQL::Translator::Generator::Role::DDL'; |
20
|
|
|
|
|
|
|
|
21
|
179
|
|
|
179
|
0
|
398
|
sub name_sep { q(.) } |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub _build_type_map { |
24
|
|
|
|
|
|
|
+{ |
25
|
8
|
|
|
8
|
|
168
|
set => 'varchar', |
26
|
|
|
|
|
|
|
bytea => 'blob', |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub _build_sizeless_types { |
31
|
|
|
|
|
|
|
+{ |
32
|
8
|
|
|
8
|
|
470
|
text => 1, |
33
|
|
|
|
|
|
|
blob => 1, |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
sub _build_numeric_types { |
37
|
|
|
|
|
|
|
+{ |
38
|
5
|
|
|
5
|
|
178
|
int => 1, |
39
|
|
|
|
|
|
|
integer => 1, |
40
|
|
|
|
|
|
|
tinyint => 1, |
41
|
|
|
|
|
|
|
smallint => 1, |
42
|
|
|
|
|
|
|
mediumint => 1, |
43
|
|
|
|
|
|
|
bigint => 1, |
44
|
|
|
|
|
|
|
'unsigned big int' => 1, |
45
|
|
|
|
|
|
|
int2 => 1, |
46
|
|
|
|
|
|
|
int8 => 1, |
47
|
|
|
|
|
|
|
numeric => 1, |
48
|
|
|
|
|
|
|
decimal => 1, |
49
|
|
|
|
|
|
|
boolean => 1, |
50
|
|
|
|
|
|
|
real => 1, |
51
|
|
|
|
|
|
|
double => 1, |
52
|
|
|
|
|
|
|
'double precision' => 1, |
53
|
|
|
|
|
|
|
float => 1, |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub _build_unquoted_defaults { |
58
|
|
|
|
|
|
|
+{ |
59
|
0
|
|
|
0
|
|
0
|
NULL => 1, |
60
|
|
|
|
|
|
|
'now()' => 1, |
61
|
|
|
|
|
|
|
CURRENT_TIMESTAMP => 1, |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
71
|
|
|
71
|
0
|
1711
|
sub nullable { () } |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub _ipk { |
68
|
109
|
|
|
109
|
|
194
|
my ($self, $field) = @_; |
69
|
|
|
|
|
|
|
|
70
|
109
|
|
|
|
|
1719
|
my $pk = $field->table->primary_key; |
71
|
109
|
100
|
|
|
|
1811
|
my @pk_fields = $pk ? $pk->fields : (); |
72
|
|
|
|
|
|
|
|
73
|
109
|
100
|
0
|
|
|
1582
|
$field->is_primary_key && scalar @pk_fields == 1 && |
|
|
|
33
|
|
|
|
|
|
|
|
100
|
|
|
|
|
74
|
|
|
|
|
|
|
( $field->data_type =~ /int(eger)?$/i |
75
|
|
|
|
|
|
|
|| |
76
|
|
|
|
|
|
|
( $field->data_type =~ /^number?$/i && $field->size !~ /,/ ) ) |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub field_autoinc { |
80
|
108
|
|
|
108
|
0
|
1313
|
my ($self, $field) = @_; |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
return ( |
83
|
|
|
|
|
|
|
( |
84
|
108
|
100
|
66
|
|
|
1690
|
($field->extra->{auto_increment_type}||'') eq 'monotonic' |
85
|
|
|
|
|
|
|
and |
86
|
|
|
|
|
|
|
$self->_ipk($field) |
87
|
|
|
|
|
|
|
and |
88
|
|
|
|
|
|
|
$field->is_auto_increment |
89
|
|
|
|
|
|
|
) |
90
|
|
|
|
|
|
|
? 'AUTOINCREMENT' |
91
|
|
|
|
|
|
|
: '' |
92
|
|
|
|
|
|
|
); |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
sub field { |
96
|
108
|
|
|
108
|
0
|
222
|
my ($self, $field) = @_; |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
|
99
|
108
|
100
|
100
|
|
|
284
|
return join ' ', |
100
|
|
|
|
|
|
|
$self->field_comments($field), |
101
|
|
|
|
|
|
|
$self->field_name($field), |
102
|
|
|
|
|
|
|
( $self->_ipk($field) |
103
|
|
|
|
|
|
|
? ( 'INTEGER PRIMARY KEY' ) |
104
|
|
|
|
|
|
|
: ( $self->field_type($field) ) |
105
|
|
|
|
|
|
|
), |
106
|
|
|
|
|
|
|
( $self->field_autoinc($field) || () ), |
107
|
|
|
|
|
|
|
$self->field_nullable($field), |
108
|
|
|
|
|
|
|
$self->field_default($field, { |
109
|
|
|
|
|
|
|
NULL => 1, |
110
|
|
|
|
|
|
|
'now()' => 1, |
111
|
|
|
|
|
|
|
'CURRENT_TIMESTAMP' => 1, |
112
|
|
|
|
|
|
|
}), |
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
1; |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=head1 AUTHORS |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
See the included AUTHORS file: |
120
|
|
|
|
|
|
|
L |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=head1 COPYRIGHT |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
Copyright (c) 2012 the SQL::Translator L as listed above. |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=head1 LICENSE |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
This code is free software and may be distributed under the same terms as Perl |
129
|
|
|
|
|
|
|
itself. |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=cut |