[Catalyst] Re: Adding relationships to loaded CDBI models
Bill Moseley
moseley at hank.org
Wed Jun 22 08:57:38 CEST 2005
On Tue, Jun 21, 2005 at 09:10:24AM -0400, James Tolley wrote:
> Can we agree that where there is a single primary key column
> referring to the primary key of another table, then that is a might_have
> relationship? If so, let's patch Class::DBI::Loader::mysql. I will volunteer
> to write the code, including tests.
Would that be Class::DBI::Loader::Generic? Why is that mysql
specific?
> The other thing on my mind is has_many mapping relationships. Can we also
> agree that where there is a table with a two-field primary key in which each
> field refers to the primary key of another table, then that is a has_many
> mapping relationship? If so, let's write that as well. I'll be happy to do
> it, if there's a consensus.
What relationships would be setup automatically?
Film->has_many(stars => [ Role => 'actor' ]);
Actor->has_many(films => [ Role => 'film' ]);
Would that be limited to mapping tables that had only two columns?
I have mapping tables with extra data in them. Somewhat as described
in:
http://wiki.class-dbi.com/index.cgi?ComplexManyToMany
BTW -- would having CDBI::Loader set up has_a with inflate/deflate
be a nice addition for timestamps and boolean? I have a lot of
timestamp columns and it would be nice to automatically setup those
up with DateTime or Time::Piece.
--
Bill Moseley
moseley at hank.org
More information about the Catalyst
mailing list