DBIx::...eValues(3pm)
π DBIx::Class::Helper::Row::StorageValues π
okay bestie, welcome to the page formerly known as DBIx::...eValues(3pm) in the User Contributed Perl Documentation section β yes the title got truncated by the man renderer, tragic, but the real name is the whole thing up top and we're gonna say it with our whole chest π«Ά
β¨ NAME β¨
DBIx::Class::Helper::Row::StorageValues β keep track of stored vs in-memory row values π
like, what's in the database rn vs. what's in your object rn. two different things. we're tracking both.
πΈ SYNOPSIS πΈ
package MyApp::Schema::Result::BlogPost;
use parent 'DBIx::Class::Core';
__PACKAGE__->load_components(qw(Helper::Row::StorageValues));
__PACKAGE__->table('BlogPost');
__PACKAGE__->add_columns(
id => {
data_type => 'integer',
is_auto_increment => 1,
},
title => {
data_type => 'varchar',
length => 32,
keep_storage_value => 1,
},
body => {
data_type => 'text',
},
);
1;
# elsewhere:
my $post = $blog_rs->create({
title => 'Components for fun and profit',
body => '...',
});
$post->title('Components for fun');
warn sprintf 'Changing title from %s to %s',
$post->storage_value('title'), $post->title;
$post->update;
see how title gets keep_storage_value => 1? that's the whole vibe. that's the column we're watching π
π¦ DESCRIPTION π¦
okay so this component keeps track of the value for a given column in the database. that's it. that's the job. iconic.
here's the tea: if you change the column's value and you do not call update, the storage_value will be different from what's in memory. and once update is called, the storage_value gets set to the value of the accessor. slay, synced, periodt.
π important distinction alert π the fact that it uses the accessor is a big deal, not a little deal. if you're using DBIx::Class::FilterColumn or DBIx::Class::InflateColumn, you'll get the non-storage or inflated values respectively. no cap, write that down.
π METHODS π
π _has_storage_value
$self->_has_storage_value('colname')
returns true if we should store the storage value from the database. fr fr, that's it.
want storage on all the integers or something chaotic like that? override it bestie:
sub _has_storage_value {
my ( $self, $column ) = @_;
my $info = $self->column_info($column);
return defined $info->{data_type} && $info->{data_type} eq 'integer';
}
go off, honestly. customize away.
π storage_value_columns
$self->storage_value_columns
returns a list of columns to store β¨ (the roster, the lineup, the chosen ones)
π get_storage_value
$self->get_storage_value('colname')
returns the value for that column which is in storage πΎ β the database's version, the original, the pre-glow-up.
π« 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 π§β¨ perl v5.40.0, dated 2024-11-16 β that's the version and the date from the footer, we're shouting them out on the way out the door. 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