From: Ken Youens-C. <ky...@gm...> - 2005-11-03 23:01:43
|
Hi, I believe I've located a bug in the way the "links_to" works as described under "Advanced 'links_to' configuration" here: http://search.cpan.org/~cwinters/SPOPS-0.87/SPOPS/Manual/ Relationships.pod 1: links_to => { 'My::Book' => 2: { table => 'publisher_book', 3: to_id_field => 'b_id', 4: from_id_field => 'p_id', }, 5: } Looking at "SPOPS::ClassFactory::DBI," I see that the "from_id_field" is captured into a variable: $from_id_field = $link_info->{from_id_field} || $this_id_field; And then just below that the substitutions are made like so: my $link_subs = $generic_linksto; $link_subs =~ s/%%ID_FIELD%%/$this_id_field/g; $link_subs =~ s/%%GEN_CLASS%%/$class/g; $link_subs =~ s/%%LINKSTO_CLASS%%/$to_class/g; $link_subs =~ s/%%LINKSTO_ALIAS%%/$to_alias/g; $link_subs =~ s/%%LINKSTO_ID_FIELD%%/$to_id_field/g; But nowhere is the $from_id_field var used in a substitution. Further, there is nowhere in the template to use it. It seems that somewhere around here: sub %%GEN_CLASS%%::%%LINKSTO_ALIAS%% { my ( $self, $p ) = @_; my $log = Log::Log4perl::get_logger(); $p ||= {}; $p->{select} = [ '%%LINKSTO_ID_FIELD%%' ]; $p->{from} = [ '%%LINKSTO_TABLE%%' ]; my $id_clause = $self->id_clause( $self->id, 'noqualify', $p ); That it should be used in the generation of the $id_clause variable. This is killing me right now because I have a primary key "div_stock.div_stock_id" that is used as a foreign key in a table called "div_allele_assay" as "div_ref_stock_id." In my "div_stock" config, I try describing the "links_to" like so: links_to => { 'GDPDM::SPOPS::DivAlleleAssay' => { table => 'div_allele_assay', from_id_field => 'div_ref_stock_id', }, But it's not working. I've been mucking around with the code, but everytime I try fixing one thing, I end up breaking another. Is there anyone who can help me with this? ky |