| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package DBIx::Class::Helper::ColumnNames; |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# ABSTRACT: Retrieve column names from a resultset |
|
4
|
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
574051
|
use v5.20; |
|
|
1
|
|
|
|
|
6
|
|
|
6
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
96
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
653
|
use parent 'DBIx::Class'; |
|
|
1
|
|
|
|
|
394
|
|
|
|
1
|
|
|
|
|
7
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
761
|
use Ref::Util qw( is_plain_hashref is_ref ); |
|
|
1
|
|
|
|
|
4652
|
|
|
|
1
|
|
|
|
|
164
|
|
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
# RECOMMEND PREREQ: Ref::Util::XS |
|
13
|
|
|
|
|
|
|
|
|
14
|
1
|
|
|
1
|
|
848
|
use experimental qw( lexical_subs postderef signatures ); |
|
|
1
|
|
|
|
|
5354
|
|
|
|
1
|
|
|
|
|
7
|
|
|
15
|
|
|
|
|
|
|
|
|
16
|
1
|
|
|
1
|
|
283
|
use namespace::clean; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
15
|
|
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
our $VERSION = 'v0.1.3'; |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
|
|
21
|
8
|
|
|
8
|
1
|
864728
|
sub get_column_names ($self) { |
|
|
8
|
|
|
|
|
12
|
|
|
|
8
|
|
|
|
|
12
|
|
|
22
|
8
|
|
|
|
|
10
|
my @columns; |
|
23
|
|
|
|
|
|
|
|
|
24
|
12
|
|
|
12
|
|
12
|
state sub _get_name ($col) { |
|
|
12
|
|
|
|
|
16
|
|
|
|
12
|
|
|
|
|
13
|
|
|
25
|
12
|
100
|
|
|
|
22
|
if ( is_plain_hashref($col) ) { |
|
26
|
5
|
|
|
|
|
37
|
my (@names) = grep { $_ !~ /^\-/ } keys $col->%*; |
|
|
6
|
|
|
|
|
18
|
|
|
27
|
5
|
|
|
|
|
14
|
return @names; |
|
28
|
|
|
|
|
|
|
} |
|
29
|
|
|
|
|
|
|
else { |
|
30
|
7
|
50
|
|
|
|
9
|
die "Cannot determine column name from a reference" if is_ref($col); |
|
31
|
7
|
|
|
|
|
20
|
return $col =~ s/^\w+\.//r; |
|
32
|
|
|
|
|
|
|
} |
|
33
|
|
|
|
|
|
|
} |
|
34
|
|
|
|
|
|
|
|
|
35
|
8
|
|
|
|
|
23
|
$self->_normalize_selection( my $attrs = $self->{attrs} ); |
|
36
|
|
|
|
|
|
|
|
|
37
|
8
|
|
|
|
|
317
|
for my $key (qw/ columns +columns as +as /) { |
|
38
|
32
|
100
|
|
|
|
86
|
next unless $attrs->{$key}; |
|
39
|
9
|
|
|
|
|
15
|
push @columns, map { _get_name($_) } $attrs->{$key}->@*; |
|
|
12
|
|
|
|
|
21
|
|
|
40
|
|
|
|
|
|
|
} |
|
41
|
|
|
|
|
|
|
|
|
42
|
8
|
100
|
|
|
|
29
|
return $self->result_source->columns unless @columns; |
|
43
|
|
|
|
|
|
|
|
|
44
|
6
|
|
|
|
|
35
|
return @columns; |
|
45
|
|
|
|
|
|
|
} |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
1; |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
__END__ |