line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package # hide from PAUSE |
2
|
|
|
|
|
|
|
DBIx::Class::CDBICompat::ImaDBI; |
3
|
|
|
|
|
|
|
|
4
|
2
|
|
|
2
|
|
479
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
53
|
|
5
|
2
|
|
|
2
|
|
9
|
use warnings; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
39
|
|
6
|
2
|
|
|
2
|
|
382
|
use DBIx::ContextualFetch; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
use DBIx::Class::_Util qw(quote_sub perlstring); |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
use base qw(Class::Data::Inheritable); |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
__PACKAGE__->mk_classdata('sql_transformer_class' => |
12
|
|
|
|
|
|
|
'DBIx::Class::CDBICompat::SQLTransformer'); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
__PACKAGE__->mk_classdata('_transform_sql_handler_order' |
15
|
|
|
|
|
|
|
=> [ qw/TABLE ESSENTIAL JOIN IDENTIFIER/ ] ); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
__PACKAGE__->mk_classdata('_transform_sql_handlers' => |
18
|
|
|
|
|
|
|
{ |
19
|
|
|
|
|
|
|
'TABLE' => |
20
|
|
|
|
|
|
|
sub { |
21
|
|
|
|
|
|
|
my ($self, $class, $data) = @_; |
22
|
|
|
|
|
|
|
return $class->result_source_instance->name unless $data; |
23
|
|
|
|
|
|
|
my ($f_class, $alias) = split(/=/, $data); |
24
|
|
|
|
|
|
|
$f_class ||= $class; |
25
|
|
|
|
|
|
|
$self->{_classes}{$alias} = $f_class; |
26
|
|
|
|
|
|
|
return $f_class->result_source_instance->name." ${alias}"; |
27
|
|
|
|
|
|
|
}, |
28
|
|
|
|
|
|
|
'ESSENTIAL' => |
29
|
|
|
|
|
|
|
sub { |
30
|
|
|
|
|
|
|
my ($self, $class, $data) = @_; |
31
|
|
|
|
|
|
|
$class = $data ? $self->{_classes}{$data} : $class; |
32
|
|
|
|
|
|
|
return join(', ', $class->columns('Essential')); |
33
|
|
|
|
|
|
|
}, |
34
|
|
|
|
|
|
|
'IDENTIFIER' => |
35
|
|
|
|
|
|
|
sub { |
36
|
|
|
|
|
|
|
my ($self, $class, $data) = @_; |
37
|
|
|
|
|
|
|
$class = $data ? $self->{_classes}{$data} : $class; |
38
|
|
|
|
|
|
|
return join ' AND ', map "$_ = ?", $class->primary_columns; |
39
|
|
|
|
|
|
|
}, |
40
|
|
|
|
|
|
|
'JOIN' => |
41
|
|
|
|
|
|
|
sub { |
42
|
|
|
|
|
|
|
my ($self, $class, $data) = @_; |
43
|
|
|
|
|
|
|
my ($from, $to) = split(/ /, $data); |
44
|
|
|
|
|
|
|
my ($from_class, $to_class) = @{$self->{_classes}}{$from, $to}; |
45
|
|
|
|
|
|
|
my ($rel_obj) = grep { $_->{class} && $_->{class} eq $to_class } |
46
|
|
|
|
|
|
|
map { $from_class->relationship_info($_) } |
47
|
|
|
|
|
|
|
$from_class->relationships; |
48
|
|
|
|
|
|
|
unless ($rel_obj) { |
49
|
|
|
|
|
|
|
($from, $to) = ($to, $from); |
50
|
|
|
|
|
|
|
($from_class, $to_class) = ($to_class, $from_class); |
51
|
|
|
|
|
|
|
($rel_obj) = grep { $_->{class} && $_->{class} eq $to_class } |
52
|
|
|
|
|
|
|
map { $from_class->relationship_info($_) } |
53
|
|
|
|
|
|
|
$from_class->relationships; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
$self->throw_exception( "No relationship to JOIN from ${from_class} to ${to_class}" ) |
56
|
|
|
|
|
|
|
unless $rel_obj; |
57
|
|
|
|
|
|
|
my $join = $from_class->storage->sql_maker->_join_condition( |
58
|
|
|
|
|
|
|
scalar $from_class->result_source_instance->_resolve_condition( |
59
|
|
|
|
|
|
|
$rel_obj->{cond}, $to, $from |
60
|
|
|
|
|
|
|
) |
61
|
|
|
|
|
|
|
); |
62
|
|
|
|
|
|
|
return $join; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
} ); |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub db_Main { |
68
|
|
|
|
|
|
|
return $_[0]->storage->dbh; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub connection { |
72
|
|
|
|
|
|
|
my ($class, @info) = @_; |
73
|
|
|
|
|
|
|
$info[3] = { %{ $info[3] || {}} }; |
74
|
|
|
|
|
|
|
$info[3]->{RootClass} = 'DBIx::ContextualFetch'; |
75
|
|
|
|
|
|
|
return $class->next::method(@info); |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
sub __driver { |
79
|
|
|
|
|
|
|
return $_[0]->storage->dbh->{Driver}->{Name}; |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
sub set_sql { |
83
|
|
|
|
|
|
|
my ($class, $name, $sql) = @_; |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
quote_sub "${class}::sql_${name}", sprintf( <<'EOC', perlstring $sql ); |
86
|
|
|
|
|
|
|
my $class = shift; |
87
|
|
|
|
|
|
|
return $class->storage->dbh_do( |
88
|
|
|
|
|
|
|
_prepare_sth => $class->transform_sql(%s, @_) |
89
|
|
|
|
|
|
|
); |
90
|
|
|
|
|
|
|
EOC |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
if ($sql =~ /select/i) { # FIXME - this should be anchore surely...? |
94
|
|
|
|
|
|
|
quote_sub "${class}::search_${name}", sprintf( <<'EOC', "sql_$name" ); |
95
|
|
|
|
|
|
|
my ($class, @args) = @_; |
96
|
|
|
|
|
|
|
$class->sth_to_objects( $class->%s, \@args); |
97
|
|
|
|
|
|
|
EOC |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
sub sth_to_objects { |
102
|
|
|
|
|
|
|
my ($class, $sth, $execute_args) = @_; |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
$sth->execute(@$execute_args); |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
my @ret; |
107
|
|
|
|
|
|
|
while (my $row = $sth->fetchrow_hashref) { |
108
|
|
|
|
|
|
|
push(@ret, $class->inflate_result($class->result_source_instance, $row)); |
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
return @ret; |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
sub transform_sql { |
115
|
|
|
|
|
|
|
my ($class, $sql, @args) = @_; |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
my $tclass = $class->sql_transformer_class; |
118
|
|
|
|
|
|
|
$class->ensure_class_loaded($tclass); |
119
|
|
|
|
|
|
|
my $t = $tclass->new($class, $sql, @args); |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
return sprintf($t->sql, $t->args); |
122
|
|
|
|
|
|
|
} |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
package |
125
|
|
|
|
|
|
|
DBIx::ContextualFetch::st; # HIDE FROM PAUSE THIS IS NOT OUR CLASS |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
no warnings 'redefine'; |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
sub _untaint_execute { |
130
|
|
|
|
|
|
|
my $sth = shift; |
131
|
|
|
|
|
|
|
my $old_value = $sth->{Taint}; |
132
|
|
|
|
|
|
|
$sth->{Taint} = 0; |
133
|
|
|
|
|
|
|
my $ret; |
134
|
|
|
|
|
|
|
{ |
135
|
|
|
|
|
|
|
no warnings 'uninitialized'; |
136
|
|
|
|
|
|
|
$ret = $sth->SUPER::execute(@_); |
137
|
|
|
|
|
|
|
} |
138
|
|
|
|
|
|
|
$sth->{Taint} = $old_value; |
139
|
|
|
|
|
|
|
return $ret; |
140
|
|
|
|
|
|
|
} |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
1; |