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

Matt Lawrence matt.lawrence at ymogen.net
Wed Mar 19 11:05:31 GMT 2008


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




More information about the Catalyst mailing list