I am trying to move some existing database to Class::DBI. I have two tables 'usr' and 'opinion' with a one to many relationship, the 'uid' in the 'opinion' table is a foreign key to the 'usr' table. The error from the code bellow suggests that the generated DELETE statement tries to use the table name in place of the foreign key field name. Or did I something wrong?
package Dl; use strict; use Data::Dumper; use base 'Class::DBI'; Dl->set_db(Main => "dbi:Pg:dbname=ab", "zby", ***); package Dl::Usr; use base 'Dl'; __PACKAGE__->table('usr'); __PACKAGE__->columns(All => qw/uid nick/); __PACKAGE__->sequence('usr_uid_seq'); __PACKAGE__->has_many(opinions => 'Dl::Opinion'); package Dl::Opinion; use base 'Dl'; __PACKAGE__->table('opinion'); __PACKAGE__->columns(All => qw/opid uid descr/); __PACKAGE__->sequence('opinion_opid_seq'); __PACKAGE__->has_a(uid => 'Dl::Usr'); package Main; my $user = Dl::Usr->create({nick => 'iwiiw'}); $user->delete; __OUTPUT__ usr is not a column of Dl::Opinion at /usr/local/share/perl/5.8.2/Clas +s/Trigger.pm line 51
perl version 5.8.2, Class::DBI version 0.95

In reply to field names and Class::DBI by zby

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.