From the docs:

If the "employee" table has a column called "depart­
ment", and there is a table in the database also named
"department", then the "department" accessor for
Employee objects will return the object referred to by
the ID in that column. The mutator will also accept an
appropriate object (or ID).
Request:
Is there anyway that you could allow the user to choose the naming convention of the foreign key? For example, i would prefer to use the name "deparment_id" instead.

UPDATE:
To elaborate more on that, offering the user the ability to specify that naming convention like so:

Class::Tables->dbh($dbh, {fk_prefix => 'fk_', fk_suffix => '_id'});
for example, would be ultra nice and seems doable. They would default to the empty string, so that if not specified, the result would be the name of the table being referenced.

Other than that, it seems pretty cool. I have only tried fetching, no deletions or insertions, but i was impressed to see i could join across two tables with:

print $_->title, ': ', $_->director_xref->director->name for Movie->search;
(and the tables)
     movie
+-------+----+
| title | id | <=
+-------+----+
      director_xref
+-------+----+----------+
| movie | id | director | =>
+-------+----+----------+
  director
+----+------+
| id | name |
+----+------+
However, while explicitly calling upon director_xref has some merits, it would be nice to be able to just say:
print $_->title, ': ', $_->directors->name for Movie->search;
but i haven't the foggiest clue how to cleanly implement/integrate that with what you have. A more valid gripe (i think) is to relax the condition that all tables must have a single primary key names 'id'. The reason is that a table like director_xref doesn't need it, instead it contains two primary keys (hence the suffix _xref). For example:
      director_xref
+----------+-------------+
| movie_id | director_id |
+----------+-------------+

All in all, very cool stuff. :)

jeffa

L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
B--B--B--B--B--B--B--B--
H---H---H---H---H---H---
(the triplet paradiddle with high-hat)

In reply to Re: Class::Tables released by jeffa
in thread Class::Tables released by blokhead

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.