NAME

DBIx::Class::SingletonRows - make database rows returned by DBIx::Class into singletons

DESCRIPTION

When you do this with DBIx::Class:

my $row = $schema->...

my $row2 = update_and_return();

sub update_and_return {
    my $row = $schema->...
    $row->somefield("HLAGH");
    $row->update();
    return $row;
}

then even if both $row and $row2 have the same row_id, they'll have different values for somefield. This irritates me, so this mixin fixes it.

SYNOPSIS

When creating the class that respresents your table, load the 'SingletonRows' component thus. Make sure to load it before you load the 'Core' component:

package MyProject::DB::Employee;

use base qw(DBIx::Class);

__PACKAGE__->load_components(qw(SingletonRows Core));

__PACKAGE__->table('employees');
...

METHODS

It wraps around DBIx::Class::Row's inflate_result() method so that it always returns singletons.

BUGS and WARNINGS

This should be considered to be pre-production code. It's probably chock full of exciting data-eating bugs.

AUTHOR, COPYRIGHT and LICENCE

Written by David Cantrell <david@cantrell.org.uk>

Copyright 2008 Outcome Technologies Ltd

This software is free-as-in-speech software, and may be used, distributed, and modified under the terms of either the GNU General Public Licence version 2 or the Artistic Licence. It's up to you which one you use. The full text of the licences can be found in the files GPL2.txt and ARTISTIC.txt, respectively.