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


DBIx-Class-SingletonRows documentation  | view source Contained in the DBIx-Class-SingletonRows distribution.

Index


NAME

Top

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

DESCRIPTION

Top

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

Top

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

Top

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

BUGS and WARNINGS

Top

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

AUTHOR, COPYRIGHT and LICENCE

Top


DBIx-Class-SingletonRows documentation  | view source Contained in the DBIx-Class-SingletonRows distribution.