[Dbix-class] Re: Result, ResultSet and load_namespaces

Alejandro Imass aimass at yabarana.com
Thu Jul 26 13:59:53 GMT 2012


On Wed, Jul 25, 2012 at 11:41 AM, Alejandro Imass <aimass at yabarana.com> wrote:
> Hi,
>
> This is my first post to the list so.... does anyone know if there is
> a searchable archive of this list?
>

[...]

>
> 1) When $schema->resultset('table')->foo() is executed which instances
> are created:
>     a) Just the ResultSet instance
>     b) Both Result and ResultSet instances?
> 2) If 1-b then is there a way for both instances to see each other?
> 3) If 1-a what is the mod elegant way to connect both classes or instances?
>
> Thanks beforehand for any pointers,
>
> --
> Alejandro Imass

Thanks, Adam for the pointers!

I read through a lot of the archives on the topic and similar topics,
and as I suspected, this is something many people struggle with.

It would seem obvious to many that the "ResultSet" directory name
would refer to extend methods at the ResultSet level (duh!), but _a
lot of people_ seem to interpret that the ResultSet classes are an
elegant way of extending the row-level classes of the Result
directory, and this IMHO is where a lot of the confusion stems from.

It may sound stupid, but adding something like this to the pod(s) may
help the incautious in the future:

<<
ResultSet classes are an elegant way to extend the ResultSet methods,
NOT the row-level methods defined in the Result ("source") classes.
>>

I know it may sound silly but I've been working with Catalyst and DBIC
for a _long time_ and I've always had this confusion until reading all
these threads. I mean it's almost impossible to know every layer at
every level so when you find something that works reasonably well and
is somewhat elegant you can stick to it for years without truly
understanding some very basic principles.

So now I ask:

The elegant way to extend row-level methods is by extending the code
in the Result classes below the checksum created by Loader?

Or are there other elegant ways to cleanly separate custom extensions
to row-level classes?

Thanks,

-- 
Alejandro Imass



More information about the DBIx-Class mailing list