[Dbix-class] Left join with an extra condition
Bill Moseley
moseley at hank.org
Mon Oct 26 00:16:23 GMT 2009
On Sun, Oct 25, 2009 at 6:54 AM, Peter Rabbitson
<rabbit+dbic at rabbit.us<rabbit%2Bdbic at rabbit.us>
> wrote:
>
>
>
> 1) Create a virtual view resultsource, and give it a specific result_class
> via ->resultset_attributes (which will add the result_class setting to
> every
> resultset class spawned from the virtual source)
>
>
I'm not sure how practical that approach is. I've always thought of the
virtual views being of limited use for custom SQL.
I tried this approach for this specific problem. I did set the
"result_class" attribute and indeed got objects blessed into that class.
But, they didn't not function as those objects -- namely I could not call
relationship methods.
I suppose the relationships can be defined in the virtual view class, but
that's not very DRY if I have a large number of custom SQL views for the
same result class. Is there a way to make the custom views act just like
the result class?
I would find it more "natural" to define the custom SQL in my ResultSet
classes -- so that I could do:
@artist =3D $schema->resultset( 'Artist' )->outside_gigs;
But, I guess outside_gigs() can always proxy to the virtual view. Again,
it's not much use if the resulting objects don't act just like a normal
Artist object where relationships still work.
Thanks again for your help, Peter.
-- =
Bill Moseley
moseley at hank.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/dbix-class/attachments/20091025/241=
99965/attachment.htm
More information about the DBIx-Class
mailing list