[Catalyst] How do I access 'Catalysed' custom datasets?

Ian Sillitoe ian at sillit.com
Thu Mar 20 14:16:26 GMT 2008


Ah, good question - composing my response helped me figure out the
answer. Thanks.

I was getting confused by use of class methods in the
DBIx::Class::Manual::Cookbook example - I've changed things around so
that I only access the schema via instance methods and everything
works fine.

Many thanks.

Ian

On Wed, Mar 19, 2008 at 11:05 AM, Matt Lawrence
<matt.lawrence at ymogen.net> wrote:
>
> Ian Sillitoe wrote:
> > This may be more of a DBIx::Class issue - if so, apologies - however I
> > think it come down to my lack of understanding of exactly what
> > Catalyst is doing when it loads DBIx::Class modules hence why I've
> > posted this problem to the catalyst mailing list.
> >
> > I need to do some sub-selects in DBIx::Class so I've written a
> > function that returns a custom resultset depending on some variables -
> > if the resultset hasn't already been created then it creates and
> > registers this resultset before returning it (based on
> > DBIx::Class::Manual::Cookbook - "Arbitrary SQL through a custom
> > ResultSource").
> >
> >
> > package MySchema::Domain;
> >
> > [...]
>
> > And if I access this new resultset directly then everything works as
> > expected:
> >
> > @entries = MyApp->model("MySchema::ResultSetFrom1To2")->search({}, {
> > bind => \@bind_values });
> >
> > However, I would prefer to access the resultset via the same method
> > that I'm creating them from rather than having to know what these
> > resultsets happen to be called under the hood or worry about typos -
> > i.e. use the method MySchema::Domain::get_custom_resultset($from, $to)
> >
> > However, I can't get this to work as expected - the following code
> > gives me the error:
> > undef error - Can't call method "select" on an undefined value at /opt/perl-5.8.8/lib/site_perl/5.8.8/DBIx/Class/ResultSet.pm line 514.
> >
> How are you getting the schema object?
>
> I would expect $c->model('MySchema')->schema->get_custom_resultset(...)
> to work.
>
> Matt
>
>
> _______________________________________________
> List: Catalyst at lists.scsys.co.uk
> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
> Dev site: http://dev.catalyst.perl.org/
>



More information about the Catalyst mailing list