[Dbix-class] Next problem with 0.8126 , many-to-many an +colums

Rolf Schaufelberger rs at plusw.de
Mon Jan 17 13:50:49 GMT 2011


I've found another  issue where the update breaks old code:

Given the following definitions:

package PW::Iprinter::DB::Article;

...
__PACKAGE__->has_many ( article_children => 'PW::Iprinter::DB::ArticleArticle', 'parent_id');
..

__PACKAGE__->many_to_many ( children  => 'article_children', 'child' );


and 

package PW::Iprinter::DB::ArticleArticle;
…

__PACKAGE__->belongs_to (child    => 'PW::Iprinter::DB::Article', 'child_id');
__PACKAGE__->belongs_to (parent => 'PW::Iprinter::DB::Article', 'parent_id');
…

(table definition : ( parent_id integer foreign key references article(id), 
                              child_id integer foreign key references article(id), 
	                      mode character varying(10) )

The following statement gives an error:

my @article = $proto->children ({article_group_id => 1009, active=>1}, 
                       {order_by=>'sort', '+columns' => ['me.mode'] }); 

($proto is a  PW::Iprinter::DB::Article )

The sql and the  error is :

SELECT child.id, child.name, child.article_group_id, child.sort, child.active, me.mode FROM article_article me JOIN article child ON child.id = me.child_id WHERE ( ( ( active = ? AND article_group_id = ? ) AND me.parent_id = ? ) ) ORDER BY sort: '1', '1009', '1049'

No such relationship 'me' on Article at /usr/local/share/perl/5.10.1/DBIx/Class/Schema.pm line 1061
	DBIx::Class::Schema::throw_exception('PW::Iprinter::Sites::Fas::DB=HASH(0x88ee018)', 'No such relationship \'me\' on Article') called at /usr/local/share/perl/5.10.1/DBIx/Class/ResultSource.pm line 1754
	DBIx::Class::ResultSource::throw_exception('DBIx::Class::ResultSource::Table=HASH(0x9209e68)', 'No such relationship \'me\' on Article') called at /usr/local/share/perl/5.10.1/DBIx/Class/ResultSource.pm line 1703
	DBIx::Class::ResultSource::related_source('DBIx::Class::ResultSource::Table=HASH(0x9209e68)', 'me') called at /usr/local/share/perl/5.10.1/DBIx/Class/Row.pm line 1162
	DBIx::Class::Row::inflate_result('PW::Iprinter::DB::Article', 'DBIx::Class::ResultSource::Table=HASH(0x9209e68)', 'HASH(0x955f8a0)', 'HASH(0x955f220)') called at /usr/local/share/perl/5.10.1/DBIx/Class/ResultSet.pm line 1148
	DBIx::Class::ResultSet::_construct_object('DBIx::Class::ResultSet=HASH(0x9556dc0)', 6021, '135g_Bilderdruck_matt', 1009, 11, 1, undef, undef, undef, ...) called at /usr/local/share/perl/5.10.1/DBIx/Class/ResultSet.pm line 1577
	DBIx::Class::ResultSet::all('DBIx::Class::ResultSet=HASH(0x9556dc0)') called at /usr/local/share/perl/5.10.1/DBIx/Class/Relationship/ManyToMany.pm line 77
	PW::Iprinter::DB::Article::children('PW::Iprinter::DB::Article=HASH(0x9557190)', 'HASH(0x936e0f8)', 'HASH(0x95335b8)') called at /home/rs/perl/xx.pl line 34

the sql  defines a correct alias me. 
Omiting the '+columns ..' part, the select works. 

DBIx::Class::VERSION = 0.8126





More information about the DBIx-Class mailing list