DBIx::...Columns(3pm)
β¨ NAME β¨
okay so bestie, this is DBIx::Class::Helper::ResultSet::AutoRemoveColumns (it's a Perl module, from the User Contributed Perl Documentation crew π
) and it does exactly one iconic thing: it automatically removes columns from a ResultSet. no cap. that's the whole gig. π
πΈ SYNOPSIS πΈ
like, here's the vibe. you set up your Result class:
package MySchema::Result::Bar;
use strict;
use warnings;
use parent 'DBIx::Class::Core';
__PACKAGE__->table('KittenRobot');
__PACKAGE__->add_columns(
id => {
data_type => 'integer',
is_auto_increment => 1,
},
kitten => {
data_type => 'integer',
},
robot => {
data_type => 'text',
is_nullable => 1,
},
your_mom => {
data_type => 'blob',
is_nullable => 1,
remove_column => 0,
},
);
1;
then your ResultSet class pulls in the component:
package MySchema::ResultSet::Bar;
use strict;
use warnings;
use parent 'DBIx::Class::ResultSet';
__PACKAGE__->load_components('Helper::ResultSet::AutoRemoveColumns');
and boom π the heavy columns justβ¦ stop showing up. slay.
π¦ DESCRIPTION π¦
so this component automatically removes "heavy-weight" columns. and when we say heavy-weight, we mean it literally, specifically these data types:
textntextblobclobbytea
those ones. all of them. gone. by default. π
but bestie, you're the main character β you get a say. you can use the remove_column key inside the column info to say directly whether or not a column should get auto-removed. it's giving control. it's giving agency. π
and if you wanna apply this whole thing across your entire schema, go peek at"NOTE"inDBIx::Class::Helper::ResultSetβ there's a nice way to do it. iykyk. β¨
π METHODS π
_should_column_fetch
here's how you call it:
$self->_should_column_fetch('kitten')
it returns true if a column should be fetched, and false if it shouldn't. simple as that fr fr.
the logic: it fetches a column if the column is not one of text, ntext, blob, clob, or bytea β or if remove_column is set to true. either one gets you in. π«Ά
now. say you're the type of girl who wants to only explicitly state which columns to remove and nothing else? you'd override this method like this:
sub _should_column_fetch {
my ( $self, $column ) = @_;
my $info = $self->result_source->column_info($column);
return exists $info->{remove_column}
? $info->{remove_column}
: 0;
}
look at that. chef's kiss. πβ¨
fetchable_columns
simply returns a list of columns that are fetchable. that's it. that's the whole method. iconic behaviour, honestly. π
π AUTHOR π
Arthur Axel "fREW" Schmidt <frioux+cpan@gmail.com>
π COPYRIGHT AND LICENSE π
This software is copyright (c) 2024 by Arthur Axel "fREW" Schmidt.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
and that's the whole page bestie, no notes π this was served up on the 2024-11-16 by perl v5.40.0 β thanks for reading, mwah ππΈπ¦
π¦ where this page comes from
- debian trixie: libdbix-class-helpers-perl 2.037000-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libdbix-class-helpers-perl 2.037000-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libdbix-class-helpers-perl 2.037000-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms