| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package DBIx::Class::Helper::ResultSet::RemoveColumns; |
|
2
|
|
|
|
|
|
|
$DBIx::Class::Helper::ResultSet::RemoveColumns::VERSION = '2.035000'; |
|
3
|
|
|
|
|
|
|
# ABSTRACT: Remove columns from a ResultSet |
|
4
|
|
|
|
|
|
|
|
|
5
|
56
|
|
|
56
|
|
27717
|
use strict; |
|
|
56
|
|
|
|
|
149
|
|
|
|
56
|
|
|
|
|
1660
|
|
|
6
|
56
|
|
|
56
|
|
356
|
use warnings; |
|
|
56
|
|
|
|
|
141
|
|
|
|
56
|
|
|
|
|
1495
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
56
|
|
|
56
|
|
297
|
use parent 'DBIx::Class::ResultSet'; |
|
|
56
|
|
|
|
|
137
|
|
|
|
56
|
|
|
|
|
335
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub _resolved_attrs { |
|
11
|
505
|
|
|
505
|
|
200547
|
my $self = $_[0]; |
|
12
|
|
|
|
|
|
|
|
|
13
|
505
|
|
|
|
|
1107
|
my $attrs = $self->{attrs}; # not copying on purpose... |
|
14
|
|
|
|
|
|
|
|
|
15
|
505
|
100
|
100
|
|
|
3238
|
if ( !$attrs->{columns} && !$attrs->{select} && $attrs->{remove_columns} ) { |
|
|
|
|
100
|
|
|
|
|
|
16
|
54
|
|
|
|
|
182
|
my %rc = map { $_ => 1 } @{$attrs->{remove_columns}}; |
|
|
158
|
|
|
|
|
502
|
|
|
|
54
|
|
|
|
|
223
|
|
|
17
|
|
|
|
|
|
|
$attrs->{columns} = [ |
|
18
|
54
|
|
|
|
|
355
|
grep { !$rc{$_} } $self->result_source->columns |
|
|
212
|
|
|
|
|
1035
|
|
|
19
|
|
|
|
|
|
|
] |
|
20
|
|
|
|
|
|
|
} |
|
21
|
|
|
|
|
|
|
|
|
22
|
505
|
|
|
|
|
6109
|
return $self->next::method; |
|
23
|
|
|
|
|
|
|
} |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
1; |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
__END__ |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=pod |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=head1 NAME |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
DBIx::Class::Helper::ResultSet::RemoveColumns - Remove columns from a ResultSet |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
package MySchema::ResultSet::Bar; |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
use strict; |
|
40
|
|
|
|
|
|
|
use warnings; |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
use parent 'DBIx::Class::ResultSet'; |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
__PACKAGE__->load_components('Helper::ResultSet::RemoveColumns'); |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
# in code using resultset: |
|
47
|
|
|
|
|
|
|
my $rs = $schema->resultset('Bar')->search(undef, { |
|
48
|
|
|
|
|
|
|
remove_columns => ['giant_text_col', 'password'], |
|
49
|
|
|
|
|
|
|
}); |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
This component allows convenient removal of columns from a select. |
|
54
|
|
|
|
|
|
|
Normally to do this you would do this by listing all of the columns |
|
55
|
|
|
|
|
|
|
B<except> the ones you want to remove. This does that part for you. |
|
56
|
|
|
|
|
|
|
See L<DBIx::Class::Helper::ResultSet/NOTE> for a nice way to apply it to |
|
57
|
|
|
|
|
|
|
your entire schema. |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
It doesn't get a lot more complicated than the synopsis. If you are interested |
|
60
|
|
|
|
|
|
|
in having more control, check out |
|
61
|
|
|
|
|
|
|
L<DBIx::Class::Helper::ResultSet::AutoRemoveColumns>. |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=over |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=item * |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
Load the component |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=item * |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
Put an C<ArrayRef> of columns to remove in the C<remove_columns> search attribute. |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=item * |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
Profit. |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=back |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=head1 AUTHOR |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
Arthur Axel "fREW" Schmidt <frioux+cpan@gmail.com> |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
This software is copyright (c) 2020 by Arthur Axel "fREW" Schmidt. |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
|
88
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=cut |