line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Ado::Model; #The schema/base class |
2
|
24
|
|
|
24
|
|
999795
|
use 5.010001; |
|
24
|
|
|
|
|
93
|
|
3
|
24
|
|
|
24
|
|
140
|
use strict; |
|
24
|
|
|
|
|
62
|
|
|
24
|
|
|
|
|
642
|
|
4
|
24
|
|
|
24
|
|
110
|
use warnings; |
|
24
|
|
|
|
|
51
|
|
|
24
|
|
|
|
|
914
|
|
5
|
24
|
|
|
24
|
|
121
|
use utf8; |
|
24
|
|
|
|
|
51
|
|
|
24
|
|
|
|
|
194
|
|
6
|
24
|
|
|
24
|
|
10255
|
use parent qw(DBIx::Simple::Class); |
|
24
|
|
|
|
|
6122
|
|
|
24
|
|
|
|
|
158
|
|
7
|
24
|
|
|
24
|
|
58162
|
use Carp; |
|
24
|
|
|
|
|
52
|
|
|
24
|
|
|
|
|
1934
|
|
8
|
24
|
|
|
24
|
|
14763
|
use DBIx::Simple::Class::Schema; |
|
24
|
|
|
|
|
64740
|
|
|
24
|
|
|
|
|
9144
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
11
|
0
|
|
|
0
|
1
|
0
|
sub is_base_class { return 1 } |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub dbix { |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
# Singleton DBIx::Simple instance |
16
|
437
|
|
|
437
|
1
|
117665
|
state $DBIx; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
# uncoverable statement |
19
|
437
|
|
33
|
|
|
3228
|
return ($_[1] ? ($DBIx = $_[1]) : $DBIx) |
20
|
|
|
|
|
|
|
|| Carp::croak('DBIx::Simple is not instantiated. Please first do ' |
21
|
|
|
|
|
|
|
. $_[0] |
22
|
|
|
|
|
|
|
. '->dbix(DBIx::Simple->connect($DSN,$u,$p,{...})'); |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
#The methods below are not generated but written additionally |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub select_range { |
29
|
4
|
|
|
4
|
1
|
9
|
my $class = shift; |
30
|
4
|
|
|
|
|
16
|
state $dbix = $class->dbix; |
31
|
4
|
|
|
|
|
28
|
my $SQL = $class->SQL('SELECT') . $class->SQL_LIMIT(@_); |
32
|
4
|
|
|
|
|
132
|
return $dbix->query($SQL)->objects($class); |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
# Generates classes from tables on the fly and returns the classname. |
36
|
|
|
|
|
|
|
sub table_to_class { |
37
|
2
|
|
|
2
|
1
|
41
|
my ($class, $args) = shift->_get_obj_args(@_); |
38
|
2
|
|
|
|
|
23
|
state $tables = {}; |
39
|
2
|
|
|
|
|
5
|
my $table = $args->{table}; |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
# already generated? |
42
|
2
|
50
|
|
|
|
10
|
return $tables->{$table} if (exists $tables->{$table}); |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
# uncoverable branch false |
45
|
2
|
|
33
|
|
|
11
|
$args->{namespace} //= $class; |
46
|
2
|
|
|
|
|
12
|
my $class_name = $args->{namespace} . '::' . Mojo::Util::camelize($table); |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
# loaded from file? |
49
|
|
|
|
|
|
|
return $tables->{$table} = $class_name |
50
|
2
|
50
|
|
|
|
45
|
if $INC{Mojo::Util::class_to_path($class_name)}; |
51
|
2
|
|
50
|
|
|
40
|
state $connected = DBIx::Simple::Class::Schema->dbix($class->dbix) && 1; |
52
|
|
|
|
|
|
|
my $perl_code = DBIx::Simple::Class::Schema->load_schema( |
53
|
|
|
|
|
|
|
namespace => $args->{namespace}, |
54
|
|
|
|
|
|
|
table => $table, |
55
|
2
|
|
50
|
|
|
50
|
type => $args->{type} || "'TABLE','VIEW'", |
56
|
|
|
|
|
|
|
); |
57
|
2
|
50
|
|
34
|
|
16490
|
Carp::croak($@) unless (eval "{$perl_code}"); ## no critic (ProhibitStringyEval) |
|
34
|
|
|
10
|
|
1679
|
|
|
10
|
|
|
12
|
|
526
|
|
|
12
|
|
|
9
|
|
20971
|
|
|
9
|
|
|
13
|
|
183
|
|
|
13
|
|
|
2
|
|
377
|
|
|
4
|
|
|
|
|
107
|
|
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
108
|
|
|
2
|
|
|
|
|
9
|
|
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
17
|
|
|
2
|
|
|
|
|
127
|
|
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
15
|
|
58
|
|
|
|
|
|
|
|
59
|
2
|
|
|
|
|
8
|
$tables->{$table} = $class_name; |
60
|
2
|
|
|
|
|
11
|
return $tables->{$table}; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
1; |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
__END__ |