1DBIx::Class::Helper::RoUws:e:rStCoornatgreiVbaultueDedBsI(Px3e:)r:lClDaoscsu:m:eHnetlapteiro:n:Row::StorageValues(3)
2
3
4

NAME

6       DBIx::Class::Helper::Row::StorageValues - Keep track of stored vs
7       in-memory row values
8

SYNOPSIS

10        package MyApp::Schema::Result::BlogPost;
11
12        use parent 'DBIx::Class::Core';
13
14        __PACKAGE__->load_components(qw(Helper::Row::StorageValues));
15
16        __PACKAGE__->table('BlogPost');
17        __PACKAGE__->add_columns(
18           id => {
19              data_type         => 'integer',
20              is_auto_increment => 1,
21           },
22           title => {
23              data_type          => 'varchar',
24              length             => 32,
25              keep_storage_value => 1,
26           },
27           body => {
28              data_type => 'text',
29           },
30        );
31
32        1;
33
34        # elsewhere:
35
36        my $post = $blog_rs->create({
37          title => 'Components for fun and profit',
38          body  => '...',
39        });
40
41        $post->title('Components for fun');
42
43        warn sprintf 'Changing title from %s to %s',
44          $post->storage_value('title'), $post->title;
45
46        $post->update;
47

DESCRIPTION

49       This component keeps track of the value for a given column in the
50       database.  If you change the column's value and do not call "update",
51       the "storage_value" will be different; once "update" is called the
52       "storage_value" will be set to the value of the accessor.  Note that
53       the fact that it uses the accessor is an important distinction.  If you
54       are using DBIx::Class::FilterColumn or DBIx::Class::InflateColumn it
55       will get the non-storage or inflated values, respectively.
56

METHODS

58   _has_storage_value
59        $self->_has_storage_value('colname')
60
61       returns true if we should store the storage value from the database.
62       Override this if you'd like to enable storage on all integers or
63       something like that:
64
65        sub _has_storage_value {
66           my ( $self, $column ) = @_;
67
68           my $info = $self->column_info($column);
69
70           return defined $info->{data_type} && $info->{data_type} eq 'integer';
71        }
72
73   storage_value_columns
74        $self->storage_value_columns
75
76       returns a list of columns to store
77
78   get_storage_value
79        $self->get_storage_value('colname')
80
81       returns the value for that column which is in storage
82

AUTHOR

84       Arthur Axel "fREW" Schmidt <frioux+cpan@gmail.com>
85
87       This software is copyright (c) 2020 by Arthur Axel "fREW" Schmidt.
88
89       This is free software; you can redistribute it and/or modify it under
90       the same terms as the Perl 5 programming language system itself.
91
92
93
94perl v5.36.0                      202D3B-I0x1:-:2C0lass::Helper::Row::StorageValues(3)
Impressum