line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package DBIx::Class::SQLA2; |
2
|
4
|
|
|
4
|
|
92769
|
use strict; |
|
4
|
|
|
|
|
12
|
|
|
4
|
|
|
|
|
121
|
|
3
|
4
|
|
|
4
|
|
37
|
use warnings; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
119
|
|
4
|
4
|
|
|
4
|
|
29
|
use feature 'postderef'; |
|
4
|
|
|
|
|
14
|
|
|
4
|
|
|
|
|
424
|
|
5
|
4
|
|
|
4
|
|
27
|
no warnings 'experimental::postderef'; |
|
4
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
154
|
|
6
|
4
|
|
|
4
|
|
25
|
use mro 'c3'; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
33
|
|
7
|
|
|
|
|
|
|
|
8
|
4
|
|
|
|
|
3514
|
use base qw( |
9
|
|
|
|
|
|
|
DBIx::Class::SQLMaker::ClassicExtensions |
10
|
|
|
|
|
|
|
SQL::Abstract |
11
|
|
|
|
|
|
|
SQL::Abstract::Classic |
12
|
4
|
|
|
4
|
|
130
|
); |
|
4
|
|
|
|
|
20
|
|
13
|
|
|
|
|
|
|
|
14
|
4
|
|
|
4
|
|
84666
|
use Role::Tiny; |
|
4
|
|
|
|
|
13433
|
|
|
4
|
|
|
|
|
42
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub _render_hashrefrefs { |
17
|
5
|
|
|
5
|
|
23
|
my ($self, $list) = @_; |
18
|
5
|
50
|
|
|
|
41
|
my @fields = ref $list eq 'ARRAY' ? @$list : $list; |
19
|
|
|
|
|
|
|
return [ |
20
|
|
|
|
|
|
|
map { |
21
|
5
|
|
|
|
|
17
|
ref $_ eq 'REF' && ref $$_ eq 'HASH' |
22
|
5
|
50
|
33
|
|
|
29
|
? do { |
23
|
5
|
|
|
|
|
27
|
my %f = $$_->%*; |
24
|
5
|
|
|
|
|
19
|
my $as = delete $f{-as}; |
25
|
|
|
|
|
|
|
\[ |
26
|
5
|
50
|
|
|
|
66
|
$as |
27
|
|
|
|
|
|
|
? $self->render_expr({ -op => [ 'as', \%f, { -ident => $as } ] }) |
28
|
|
|
|
|
|
|
: $self->render_expr(\%f) |
29
|
|
|
|
|
|
|
]; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
: $_ |
32
|
|
|
|
|
|
|
} @fields |
33
|
|
|
|
|
|
|
]; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub _recurse_fields { |
37
|
94
|
|
|
94
|
|
2752
|
my ($self, $fields) = @_; |
38
|
94
|
100
|
66
|
|
|
291
|
if (ref $fields eq 'REF' && ref $$fields eq 'HASH') { |
39
|
5
|
|
|
|
|
68
|
return $self->next::method($self->_render_hashrefrefs($fields)->[0]); |
40
|
|
|
|
|
|
|
} |
41
|
89
|
|
|
|
|
204
|
return $self->next::method($fields); |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub select { |
46
|
30
|
|
|
30
|
1
|
262678
|
my ($self, $table, $fields, $where, $rs_attrs, $limit, $offset) = @_; |
47
|
|
|
|
|
|
|
|
48
|
30
|
50
|
|
|
|
139
|
if (my $gb = $rs_attrs->{group_by}) { |
49
|
0
|
|
|
|
|
0
|
$rs_attrs = { %$rs_attrs, group_by => $self->_render_hashrefrefs($gb) }; |
50
|
|
|
|
|
|
|
} |
51
|
30
|
|
|
|
|
154
|
$self->next::method($table, $fields, $where, $rs_attrs, $limit, $offset); |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub insert { |
56
|
|
|
|
|
|
|
# TODO - this works, ish. The issue is that if you have rels involved, you may actually |
57
|
|
|
|
|
|
|
# hit `insert` before the intended insert. Not sure what to do but put that on the |
58
|
|
|
|
|
|
|
# user... |
59
|
20
|
|
|
20
|
1
|
30205
|
my ($self, $source, $cols, $attrs) = @_; |
60
|
20
|
|
50
|
|
|
149
|
$attrs ||= {}; |
61
|
20
|
100
|
|
|
|
89
|
if (my $extra_attrs = $self->{_sqla2_insert_attrs}) { |
62
|
6
|
|
|
|
|
27
|
$attrs = { %$attrs, %$extra_attrs }; |
63
|
|
|
|
|
|
|
} |
64
|
20
|
|
|
|
|
100
|
$self->next::method($source, $cols, $attrs); |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub expand_clause { |
68
|
2
|
|
|
2
|
0
|
5
|
my ($self, $clause, $value) = @_; |
69
|
2
|
|
|
|
|
5
|
my ($probably_key, $expanded) = $self->${ \$self->clause_expander($clause) }(undef, $value); |
|
2
|
|
|
|
|
47
|
|
70
|
2
|
50
|
|
|
|
916
|
if ($expanded) { |
71
|
2
|
|
|
|
|
9
|
return ($probably_key => $expanded); |
72
|
|
|
|
|
|
|
} else { |
73
|
0
|
|
|
|
|
0
|
return (undef => $probably_key); |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
sub new { |
79
|
9
|
|
|
9
|
1
|
808655
|
my $new = shift->next::method(@_); |
80
|
9
|
50
|
|
|
|
2965
|
unless (grep {m/^with$/} $new->clauses_of('select')) { |
|
36
|
|
|
|
|
244
|
|
81
|
9
|
|
|
|
|
77
|
$new->plugin("+$_") for qw/ExtraClauses WindowFunctions Upsert BangOverrides CaseExpr/; |
82
|
|
|
|
|
|
|
} |
83
|
9
|
|
|
|
|
633
|
return $new; |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
our $VERSION = '0.01_2'; |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
1; |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=encoding utf8 |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=head1 NAME |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
DBIx::Class::SQLA2 - SQL::Abstract v2 support in DBIx::Class |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head1 SYNOPSIS |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
$schema->connect_call_rebase_sqlmaker('DBIx::Class::SQLA2'); |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=head1 DESCRIPTION |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
This is a work in progress for simplifying using SQLA2 with DBIC. This is for using w/ the |
103
|
|
|
|
|
|
|
most recent version of DBIC. |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
For a simple way of using this, take a look at L. |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
B |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
This role itself will add handling of hashref-refs to select lists + group by clauses, |
110
|
|
|
|
|
|
|
which will render the inner hashref as if it had been passed through to SQLA2 rather than |
111
|
|
|
|
|
|
|
doing the recursive function rendering that DBIC does. |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=head2 Included Plugins |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
This will add the following SQLA2 plugins: |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=over 2 |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=item L |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
Adds support for CTEs, and other fun new SQL syntax |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=item L |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
Adds support for window functions and advanced aggregates. |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=item L |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
Adds support for Upserts (ON CONFLICT clause) |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=item L |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
Adds some hacky stuff so you can bypass/supplement DBIC's handling of certain clauses |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=back |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=head1 AUTHOR |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
Copyright (c) 2022 Veesh Goldman |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=head1 LICENSE |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
This module is free software; you may copy this under the same |
144
|
|
|
|
|
|
|
terms as perl itself (either the GNU General Public License or |
145
|
|
|
|
|
|
|
the Artistic License) |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=cut |