in reply to Class::Tables released
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:
UPDATE:
To elaborate more on that, offering the user the ability to specify that naming convention
like so:
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.Class::Tables->dbh($dbh, {fk_prefix => 'fk_', fk_suffix => '_id'});
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:
(and the tables)print $_->title, ': ', $_->director_xref->director->name for Movie->search;
movie
+-------+----+
| title | id | <=
+-------+----+
|
director_xref
+-------+----+----------+
| movie | id | director | =>
+-------+----+----------+
|
director +----+------+ | id | name | +----+------+ |
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:print $_->title, ': ', $_->directors->name for Movie->search;
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)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Class::Tables released
by blokhead (Monsignor) on Dec 21, 2003 at 04:57 UTC |