[Dbix-class] Problems while using the newest DBIx-Class-current

Nilson Santos Figueiredo Junior acid06 at gmail.com
Sat Jul 1 00:50:07 CEST 2006


On 6/30/06, Matt S Trout <dbix-class at trout.me.uk> wrote:
> I don't think {attrs}{alias} has been munged right as DBIC traversed the
> search_relateds in the many-many. Not sure exactly why though - can you have a
> dig around in that resultset and see what you've ended up with please?

Just in case someone is trying to go after this possible bug, I
managed to narrow down where the problem comes from. It really
originates from the search_hours_spent(). Also, I was able to reduce
it to the minimum implementation where the issue is present for the
mentioned resultset:

sub search_hours_spent {
    my $self = shift;
    my $alias = $self->{attrs}{alias};

    $self->search(
        undef,
        {
            select   => [(map {"${alias}.${_}"} $self->result_source->columns)],
        }
    );
}

Also, I thought it might be relevant to include the
MyTasks::Schema::Task definition:

package MyTasks::Schema::Task;
use warnings;
use strict;
use base qw/DBIx::Class/;
use DateTime::Format::MySQL;

my $pkg = __PACKAGE__;

$pkg->load_components(qw/PK::Auto Core/);
$pkg->table('task');
$pkg->add_columns(qw/id project_id creator_id date deadline priority
description is_closed comments parent_id/);
$pkg->set_primary_key('id');
$pkg->resultset_class('MyTasks::Schema::ResultSet::Task');

$pkg->belongs_to('project', 'MyTasks::Schema::Project', 'project_id');

$pkg->belongs_to('creator', 'MyTasks::Schema::User', 'creator_id');

$pkg->has_many('logs', 'MyTasks::Schema::TaskLog', 'task_id');

$pkg->has_many('task_users' => 'MyTasks::Schema::TaskUser', 'task_id');
$pkg->many_to_many('users' => 'task_users', 'user');

$pkg->has_many('child_tasks' => 'MyTasks::Schema::Task', 'parent_id');
$pkg->belongs_to('parent_task' => 'MyTasks::Schema::Task', 'parent_id');

# auto-inflate para objetos DateTime
$pkg->inflate_column('date', {
    inflate => sub { DateTime::Format::MySQL->parse_datetime(shift); },
    deflate => sub { DateTime::Format::MySQL->format_datetime(shift); },
});

$pkg->inflate_column('deadline', {
    inflate => sub { DateTime::Format::MySQL->parse_datetime(shift); },
    deflate => sub { DateTime::Format::MySQL->format_datetime(shift); },
});

Could it be related to the new many-to-many behaviour?

-Nilson Santos F. Jr.



More information about the Dbix-class mailing list