[Dbix-class] Detecting a "belongs_to" relationship.
Bill Moseley
moseley at hank.org
Wed Mar 24 15:22:27 GMT 2010
On Wed, Mar 24, 2010 at 7:53 AM, fREW Schmidt <frioux at gmail.com> wrote:
> I'll only answer your last issue, since it doesn't make any sense at all =
in
> DBIC context:
>
> ...
> __PACKAGE__->set_primary_key(qw( part_id customer_id ));
> ...
>
> The above class has a MultiPK. In general I don't like MultiPK but the
> fact that DBIC supports it allows us to actually use our customer's
> database. If we were to stringify this object how could that work? Do we
> do "$part_id,$customer_id"?
>
We have tables with multiple primary keys, but I can't think of a case where
we have used them in this way -- mostly it's $cd->artist where it's a single
key.
That said, stringification can be overridden, of course, to produce any
format you wish.
> *But* because DBIC is written in such a manner that everything is
> extensible you could add this feature in. I could probably make a compon=
ent
> to stringify my objects to their pk in about half an hour. I won't do it
> because I think that's just a silly thing to do; but you can, and that's =
the
> whole point.
>
I wasn't saying it was hard to stringify DBIC objects, just more remarking
what a useful feature it had been with Class::DBI. It seems silly if it's
not what you are used to. But, it turns out that it makes a bunch of code
very simple since you can often work abstract objects.
$telephone_connection->dial( $user->phone ) is a nice abstraction (even if
not the best example).
-- =
Bill Moseley
moseley at hank.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/dbix-class/attachments/20100324/9bb=
ebdf4/attachment.htm
More information about the DBIx-Class
mailing list