Indeed so! However, in your particular case it is not necessarily the context but thorough understanding of the tools used that is lacking ;-).

Same occurred to me just recently when I was playing with the Class::DBI module. My database contained a dozen tables. A few of these tables served as a cross-reference: they linked data from two tables together. So, when I set out to create a Class::DBI for a joint table like so:
package YV::Table::ArticleAuthor; use base 'YV::Table::DBI'; __PACKAGE__->table('article_authors'); __PACKAGE__->columns(All => qw/author_id article_id/); __PACKAGE__->hasa(YV::Table::Author => 'author_id'); __PACKAGE__->hasa(YV::Table::Article => 'article_id'); # other methods
And later in my code tried to do something like this:
use YV::Table::ArticleAuthor; # this is built dynamically... my %delete_article_xref = ( 23 => 1, ); # $author is an YV::Table::Author object initialized prior.. my @author_articles = YV::Table::ArticleAuthor->search(author_id => $a +uthor->id); # delete cross reference for $author and article id # (In affect, I want to 'disassociate' article with $article_id from t +he $author) for (@author_articles) { next unless $delete_article_xref{$_->article_id}; $_[0]->delete(); }
Guess what happened next from here?

Answer (select text):
As a result of invoking the delete() method on an instance of the YV::Table::ArticleAuthor object, I removed all article to author associations. That is, not just one article from a single (selected) author. This caused a little havoc with a web tool I wrote..

The actual problem rested with my lack of understanding how Class::DBI worked. Looking back at the documentation, I figured that the reason the delete() method was acting so 'strangely' was because the primary column of the YV::Table::ArticleAuthor class was in fact author_id and delete() uses this very column to construct (or rather 'restrict') it's DELETE SQL. So the quick fix to my problem was to swap the fields like so:
__PACKAGE__->columns(All => qw/article_id author_id/);
And since the first column is (by default) taken to be the primary column, delete worked as I wanted it to thereafter. ;-).


Update: err.. I submitted invalid code initially (was taking it from my head heh). This is fixed now.

_____________________
# Under Construction

In reply to Re: The importance of context in debugging by vladb
in thread The importance of context in debugging by rob_au

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.