NAME

DBIx::QuickORM::Row - A single row of data backed by a source and connection.

DESCRIPTION

The concrete row class. It consumes DBIx::QuickORM::Role::Row, which supplies the higher-level operations (insert / save, primary-key helpers, link traversal); this class supplies the low-level state and field accessors that role builds on.

Row state is held in a row-data object (see DBIx::QuickORM::Connection::RowData) that tracks three views of the data: STORED (raw values as last seen in the database), PENDING (unsaved changes), and DESYNC (fields whose stored value changed out from under pending changes). Values are inflated/deflated through the source's field types on demand.

SYNOPSIS

my $name = $row->field('name');
$row->field(name => 'New Name');
$row->save;

my $raw  = $row->raw_field('name');
my $all  = $row->fields;

ATTRIBUTES

row_data

The row-data object holding the STORED / PENDING / DESYNC views and transaction tracking. Required at construction.

PUBLIC METHODS

$bool = $row->track_desync
$source = $row->source
$conn = $row->connection
$obj = $row->row_data_obj
$data = $row->row_data
$stored = $row->stored_data
$pending = $row->pending_data
$desynced = $row->desynced_data
$bool = $row->is_invalid
$bool = $row->is_valid
$bool = $row->in_storage
$bool = $row->is_stored
$bool = $row->is_desynced
$bool = $row->has_pending

State predicates and accessors over the row-data object. row_data_obj returns the row-data object itself; row_data returns its currently active view.

$new = $row->clone(%overrides)

Return a new, unstored row carrying this row's data minus its primary-key fields, deep-cloned, with any %overrides applied on top.

$row = $row->check_sync

Croak if the row is out of sync (refreshed while it had pending changes) or was fetched outside the current transaction stack; otherwise return the row.

$row = $row->force_sync

Clear the desync flags so the row can be saved despite a detected discrepancy.

$row = $row->refresh

Re-fetch the row from the database (requires a stored row with a primary key).

$row = $row->discard

Drop pending changes and clear desync flags.

$row = $row->update(\%changes)
$row = $row->update(%changes)

Apply changes to the pending data and save the row.

$row->delete

Delete the row from the database (requires a stored row with a primary key).

$val = $row->field($name)
$row->field($name => $value)
$val = $row->raw_field($name)

Get (or, with a value, set) a single field. field returns the inflated value; raw_field returns the deflated/raw value.

$hash = $row->fields
$hash = $row->raw_fields
$val = $row->stored_field($name)
$val = $row->pending_field($name)
$val = $row->raw_stored_field($name)
$val = $row->raw_pending_field($name)
$hash = $row->stored_fields
$hash = $row->pending_fields
$hash = $row->raw_stored_fields
$hash = $row->raw_pending_fields

The various field views: fields merges pending over stored; the stored_* / pending_* variants read only that view, and the raw_* variants return deflated values instead of inflated ones.

$bool = $row->field_is_desynced($name)

True if the named field is marked out of sync.

PRIVATE METHODS

$val = $row->_field($view_method, $name)
$row->_field($view_method, $name => $value)

Shared getter/setter behind field / raw_field: resolves the value from pending or stored data (fetching a missing stored field on demand) and runs it through $view_method.

$hash = $row->_fields($view_method, @data_hashes)

Build a field-name to value hash from the given data hashes using $view_method, earlier hashes winning.

$val = $row->_inflated_field($from, $name)

Return the inflated value of $name from data hash $from, inflating and caching via the source's field type when needed.

$val = $row->_raw_field($from, $name)

Return the deflated/raw value of $name from data hash $from.

SOURCE

The source code repository for DBIx::QuickORM can be found at https://github.com/exodist/DBIx-QuickORM.

MAINTAINERS

Chad Granum <exodist@cpan.org>

AUTHORS

Chad Granum <exodist@cpan.org>

COPYRIGHT

Copyright Chad Granum <exodist7@gmail.com>.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

See https://dev.perl.org/licenses/