[Dbix-class] Error with +columns

mpm mpmagarinos at gmail.com
Fri Dec 14 20:48:22 GMT 2012


I am getting an error, that was not happening before:

my $where_o={};
                my $attr_o={};
                my @og;
                $where_o->{'me.m_id'}= $m_id;
                $where_o->{'sp.is'}='y';
                push @{ $attr_o->{join} }, {'tD' => {'g' => 'sp'}};
                $attr_o->{group_by}='me.t_id';
                $attr_o->{'+columns'}= [ qw/tD.o_id/];
                my
$ogs=$c->model('weight::T2m_id')->search($where_o,$attr_o);
                while (my $rs_ogs = $ogs->next()) {
                        my $o_group=$rs_ogs->get_column('tD.o_id');
                        push @o_groups,$o_group;
                }
                $c->stash->{o_groups}=\@o_groups;

If the search returns only one result, IT WORKS FINE. But if it returns more
than one, the following error happens:

SELECT me.m_id, me.t_id, tD.o_id FROM t2m_id me  JOIN tD ON tD.T_ID =
me.t_id LEFT JOIN g ON g.o_id = tD.o_id LEFT JOIN sp ON sp.sp_c = g.sp_c
WHERE ( ( me.m_id = ? AND sp.is = ? ) ) GROUP BY me.t_id: '452497', 'y'
[error] No such column 'tD.o_id' at
/usr/local/share/perl/5.10.1/DBIx/Class/Schema.pm line 1078
	DBIx::Class::Schema::throw_exception('weight=HASH(0xc7241f0)', 'No such
column \'tD.o_id\'') called at
/usr/local/share/perl/5.10.1/DBIx/Class/ResultSource.pm line 1968

DBIx::Class::ResultSource::throw_exception('DBIx::Class::ResultSource::Table=HASH(0xc721248)',
'No such column \'tD.o_id\'') called at
/usr/local/share/perl/5.10.1/DBIx/Class/Row.pm line 1445

DBIx::Class::Row::throw_exception('portfolio::Model::weight::T2m_id=HASH(0xcd2cae8)',
'No such column \'tD.o_id\'') called at
/usr/local/share/perl/5.10.1/DBIx/Class/Row.pm line 621

I think it has to do with the +columns

How can I correct it? and why it started to happen now??



--
View this message in context: http://dbix-class.35028.n2.nabble.com/Error-with-columns-tp7577853.html
Sent from the DBIx-Class mailing list archive at Nabble.com.



More information about the DBIx-Class mailing list