I really don't understand why this happens...

If the search is:
my $rs1 = $c->model('weight::Mdata')->search($where,$attr,{prefetch =>
'mc'},{join =>'mt'});
The DBIC TRACE shows that the join occurs between mdata and mt, and I get
the following error:
[error] DBIx::Class::ResultSet::next(): DBI Exception: DBD::mysql::st
execute failed: Unknown column 'mc.h1' in 'where clause'

Inversely, if the search is:
my $rs1 = $c->model('weight::Mdata')->search($where,$attr,{join
=>'mt'},{prefetch => 'mc'});
The DBIC TRACE shows that the join (and the prefetch) occurs between mdata
and mc, and I get the following error:
[error] DBIx::Class::ResultSet::next(): DBI Exception: DBD::mysql::st
execute failed: Unknown column 'mt.n_C' in 'where clause'

It seems as the prefetch 'erases' the join and viceversa...


2013/1/21 Paula <mpmagari...@gmail.com>

> Hi! Thank you for your answer. Unfortunately neither of the 2
> possibilities work. In both cases I get the same error:
> [error] DBIx::Class::Row::get_column(): No such column 'h1'
>
>
> 2013/1/18 Patrick Meidl <pme...@ist.ac.at>
>
>> On Fri, Jan 18 2013, mpm <mpmagari...@gmail.com> wrote:
>>
>> > push @{ $attr->{join} }, 'mt';
>> > push @{ $attr->{join} }, 'mc';
>> > my $rs1 = $c->model('weight::Mdata')->search( $where, $attr,{prefetch =>
>> > 'mc'});
>>
>> I think your curly braces are misplaced. this should do what you want:
>>
>> my $rs1 = $c->model('weight::Mdata')->search($where,
>>     { %$attr, prefetch => 'mc' });
>>
>> or alternatively:
>>
>> push @{ $attr->{join} }, 'mt';
>> push @{ $attr->{join} }, 'mc';
>> $attr->{prefetch} = 'mc';
>> my $rs1 = $c->model('weight::Mdata')->search($where, $attr);
>>
>>
>> HTH
>>
>>     patrick
>>
>> --
>> Patrick Meidl, Mag.
>> Senior Expert Software Engineering
>>
>> IST - Institute of Science and Technology Austria
>> Am Campus 1
>> A-3400 Klosterneuburg, Austria
>>
>> R 03.EG.003
>> T +43 2243 9000 1063
>> E pme...@ist.ac.at
>> W http://www.ist.ac.at/
>>
>>
>> _______________________________________________
>> List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
>> IRC: irc.perl.org#dbix-class
>> SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
>> Searchable Archive:
>> http://www.grokbase.com/group/dbix-class@lists.scsys.co.uk
>>
>
>
_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/dbix-class@lists.scsys.co.uk

Reply via email to