[CDBI] X is not a column of Y
grigorian at gmail.com
Sun Oct 7 01:15:44 BST 2007
On 10/6/07, Perrin Harkins <perrin at elem.com> wrote:
> On 10/6/07, Matt S Trout <dbix-class at trout.me.uk> wrote:
> > On Fri, Oct 05, 2007 at 09:07:27PM -0400, Edward J. Sabol wrote:
> > > Arshavir Grigorian wrote:
> > > > Following is my class structure that gives the error described in
> > > > my first email. I have tried to cut out all the extraneous stuff.
> > > > The error only results when deleting the record.
> > >
> > > Ah, you didn't mention that before.
> > The OP spent several hours on freenode#perl not mentioning that fact either.
> I think you guys missed this, from his first mail:
> "I am getting the error posted below when I try to delete from a table
> that has_many() records in another table."
> Arshavir, I'm pretty sure the problem is that you loaded Communication
> before Task. The CDBI docs for has_many say that if you don't have a
> has_a method set up to tell it which column to look at, it will use
> the moniker of the class, which is "task" in your case, and not a
> column. To fix this, you can load Task first, or use the 3-argument
> form of has_many, passing "task_id" as the last arg.
> - Perrin
Thank you very much. I have a very complex set of relationships so
controlling this sort of thing through loading order was not an
option, but supplying the third argument did the trick.
On a related note, this error occurs on selects as well and is not
specific to deletes. Since I rely on the RDBMS to enforce referential
integrity, I had missed the part where CDBI tries to do "the right
thing" on deletes by default.
More information about the ClassDBI