DBIO
view release on metacpan or search on metacpan
lib/DBIO/Row.pm view on Meta::CPAN
serialization. Automatically excludes C<text>, C<ntext>, and C<blob>
columns unless C<< is_serializable => 1 >> is set in the column info.
Numeric columns are numified for correct JSON output.
=head2 self_rs
my $rs = $row->self_rs;
Returns a ResultSet containing only this row, useful for applying
ResultSet methods to a single row.
=head2 StorageValues
Per-column opt-in snapshot of the values as last seen in storage.
Mark a column with C<< keep_storage_value => 1 >> and DBIO will record
its current stored value at C<new>, C<insert>, C<update> and
C<inflate_result> time. The snapshot uses the column accessor, so
inflated / filtered values are captured rather than raw storage values.
__PACKAGE__->add_column(title => {
data_type => 'varchar',
keep_storage_value => 1,
});
$row->title('New');
$row->get_storage_value('title'); # the old value
$row->update;
$row->get_storage_value('title'); # now 'New'
=head2 OnColumnChange
Register C<before_column_change>, C<after_column_change>, and
C<around_column_change> callbacks on a Result class. Callbacks fire
from L</update> only if the named column is actually dirty. The "old"
value comes from L</get_storage_value>, so pair this with
C<< keep_storage_value => 1 >> on the column if you need a real
previous value; otherwise it will be C<undef>.
__PACKAGE__->before_column_change(
amount => { method => 'bank_transfer', txn_wrap => 1 },
);
Callback signatures:
before: $self->$method($old, $new)
after: $self->$method($old, $new) # $old may now equal $new
around: $self->$method($next, $old, $new)
C<before> callbacks fire in definition order, C<after> callbacks fire
in reverse order, C<around> callbacks wrap in definition order (the
innermost being the first declared). If any registered arg has
C<< txn_wrap => 1 >> the whole update is wrapped in a
C<txn_scope_guard>.
See L<DBIx::Class::Helper::Row::OnColumnChange/on_column_change_allow_override_args>
for C<on_column_change_allow_override_args> semantics.
=head2 ProxyResultSetMethod
Expose a C<with_foo> ResultSet method as a row accessor with a
transparent fallback: if the column was already selected via the
ResultSet method it is returned from the cached row data; otherwise
the ResultSet method is re-run for this row.
package MyApp::Schema::ResultSet::Foo;
sub with_friend_count { ... }
package MyApp::Schema::Result::Foo;
__PACKAGE__->proxy_resultset_method('friend_count');
$foo_rs->first->friend_count; # lazy fetch
$foo_rs->with_friend_count->first->friend_count; # cached
The generated accessor stores the fetched value under the slot name in
C<_column_data> as a cache. Proxied slots are excluded from C<copy>
and C<update> so they are never written as actual columns.
=head2 id
my @pk = $result->id;
=over
=item Arguments: none
=item Returns: A list of primary key values
=back
Returns the primary key(s) for a row. Can't be called as a class method.
Actually implemented in L<DBIO::PK>
=head1 AUTHOR
DBIO & DBIx::Class Authors
=head1 COPYRIGHT AND LICENSE
Copyright (C) 2026 DBIO Authors
Portions Copyright (C) 2005-2025 DBIx::Class Authors
Based on DBIx::Class, heavily modified.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
=cut
( run in 1.231 second using v1.01-cache-2.11-cpan-7fcb06a456a )