[html-formfu] many_to_many save_to_model & defaults_from_model

viacheslav.t at gmail.com viacheslav.t at gmail.com
Mon Jan 21 20:23:42 GMT 2008


Carl Franks(fireartist at gmail.com)@Mon, Jan 21, 2008 at 07:15:48PM +0000:
> On 21/01/2008, Вячеслав Тихановский <viacheslav.t at gmail.com> wrote:
> > Hello.
> >
> > Probably I found a bug.
> >
> > If I have relationships like this:
> >
> > Bands (bandid, name)
> > -> has_many map_band_user
> > -> many_to_many genres
> >
> > Genres (genreid, name)
> > -> has_many map_band_user
> > -> many_to_many bands
> >
> > BandGenre(bandid, genreid)
> > -> belongs to band
> > -> belongs to genre
> >
> > To check genres I use the following config:
> >
> >   - type: Select
> >     name: genres
> >     label: Genres
> >     multiple: 1
> >     db:
> >       default_column: genreid
> >
> > Of course then defaults_from_model fires up with:
> >
> > DBI Exception: DBD::mysql::st execute failed: Column 'genreid' in
> > field list is ambiguous [for Statement "SELECT genreid FROM
> > bands_band_genre me JOIN bands_genres genre ON ( genre.genreid =
> > me.genreid ) WHERE ( me.bandid = ? )" with ParamValues: 0='1'] at
> > /usr/lib/perl5/vendor_perl/5.8.8/DBIx/Class/Schema.pm line 945
> 
> I think this may be down to the relationship declaration in your dbic schema.
> Because you have 2 tables with the same column name, do you need to
> provide a join condition, rather than just a column name to your
> many_to_many() declaration?
> 
> Carl

There are no problems in using my schema all over my app, I always use the same
names just not to get confused, and always use 'me.' aliasing if they are
ambiguous. The problem is that HTML::FormFu::Model::DBIC doesn't count on that.

-- 
vti -- Viacheslav Tikhanovskii



More information about the HTML-FormFu mailing list