line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package SQL::Translator::Producer::Teng; |
2
|
4
|
|
|
4
|
|
2107780
|
use 5.008001; |
|
4
|
|
|
|
|
27
|
|
|
4
|
|
|
|
|
172
|
|
3
|
4
|
|
|
4
|
|
24
|
use strict; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
137
|
|
4
|
4
|
|
|
4
|
|
24
|
use warnings; |
|
4
|
|
|
|
|
17
|
|
|
4
|
|
|
|
|
193
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = "0.03"; |
7
|
|
|
|
|
|
|
|
8
|
4
|
|
|
4
|
|
4153
|
use Text::Xslate; |
|
4
|
|
|
|
|
49102
|
|
|
4
|
|
|
|
|
254
|
|
9
|
4
|
|
|
4
|
|
4775
|
use Data::Section::Simple; |
|
4
|
|
|
|
|
2197
|
|
|
4
|
|
|
|
|
184
|
|
10
|
4
|
|
|
4
|
|
4049
|
use DBI; |
|
4
|
|
|
|
|
33471
|
|
|
4
|
|
|
|
|
199
|
|
11
|
4
|
|
|
4
|
|
1286
|
use SQL::Translator::Schema::Field; |
|
4
|
|
|
|
|
141901
|
|
|
4
|
|
|
|
|
1524
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
my $_tx; |
14
|
|
|
|
|
|
|
sub _tx { |
15
|
4
|
|
66
|
4
|
|
320
|
$_tx ||= Text::Xslate->new( |
16
|
|
|
|
|
|
|
type => 'text', |
17
|
|
|
|
|
|
|
module => ['Text::Xslate::Bridge::Star'], |
18
|
|
|
|
|
|
|
path => [Data::Section::Simple::get_data_section] |
19
|
|
|
|
|
|
|
); |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub produce { |
23
|
4
|
|
|
4
|
0
|
1893311
|
my $translator = shift; |
24
|
4
|
|
|
|
|
123
|
my $schema = $translator->schema; |
25
|
4
|
|
|
|
|
331
|
my $args = $translator->producer_args; |
26
|
|
|
|
|
|
|
|
27
|
4
|
|
|
|
|
151
|
my $package = $args->{package}; |
28
|
4
|
|
|
|
|
11
|
my $base_row_class = $args->{base_row_class}; |
29
|
|
|
|
|
|
|
|
30
|
4
|
|
|
|
|
9
|
my @tables; |
31
|
4
|
|
|
|
|
29
|
for my $table ($schema->get_tables) { |
32
|
8
|
|
|
|
|
942
|
my @pks; |
33
|
|
|
|
|
|
|
my @columns; |
34
|
8
|
|
|
|
|
43
|
for my $field ($table->get_fields) { |
35
|
52
|
|
|
|
|
33861
|
push @columns, { |
36
|
|
|
|
|
|
|
name => $field->name, |
37
|
|
|
|
|
|
|
type_name => $field->data_type, |
38
|
|
|
|
|
|
|
type => _get_dbi_const($field->sql_data_type), |
39
|
|
|
|
|
|
|
}; |
40
|
52
|
100
|
|
|
|
1265
|
push @pks, $field->name if $field->is_primary_key; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
8
|
|
|
|
|
6535
|
push @tables, { |
44
|
|
|
|
|
|
|
name => $table->name, |
45
|
|
|
|
|
|
|
pks => \@pks, |
46
|
|
|
|
|
|
|
columns => \@columns, |
47
|
|
|
|
|
|
|
}; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
4
|
|
|
|
|
411
|
_tx->render('schema.tx', { |
51
|
|
|
|
|
|
|
package => $package, |
52
|
|
|
|
|
|
|
base_row_class => $base_row_class, |
53
|
|
|
|
|
|
|
tables => \@tables, |
54
|
|
|
|
|
|
|
}); |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
my %CONST_HASH; |
58
|
|
|
|
|
|
|
sub _get_dbi_const { |
59
|
52
|
|
|
52
|
|
7707
|
my $val = shift; |
60
|
|
|
|
|
|
|
|
61
|
52
|
100
|
|
|
|
218
|
unless (%CONST_HASH) { |
62
|
3
|
|
|
|
|
7
|
for my $const_key (@{ $DBI::EXPORT_TAGS{sql_types} }) { |
|
3
|
|
|
|
|
15
|
|
63
|
174
|
|
|
|
|
645
|
my $const_val = DBI->can($const_key)->(); |
64
|
|
|
|
|
|
|
|
65
|
174
|
100
|
|
|
|
379
|
unless (exists $CONST_HASH{$const_val}) { |
66
|
165
|
|
|
|
|
365
|
$CONST_HASH{$const_val} = $const_key; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
52
|
|
|
|
|
294
|
$CONST_HASH{$val}; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
1; |
75
|
|
|
|
|
|
|
__DATA__ |