[Dbix-class] faking ResultSets

Matt S Trout dbix-class at trout.me.uk
Wed Jan 25 18:05:19 CET 2006


On Wed, Jan 25, 2006 at 03:00:58PM -0000, Richard Jolly wrote:
> Hi,
> 
> We have a growing mismatch in our code between methods that return
> ResultSet objects and those that return an array/arrayref of objects.
> This is in a Catalyst model layer.
> 
> For the sake of api consistency I'd like to have a fake ResultSet class
> that had the same api, but was just seeded with a list of objects. 
> 
>   ResultSet::Fake->new({ records => [@records] });
>  
> But I expect this wouldn't play well with the forthcoming release.
> 
> Is there a common solution to this problem? How do people keep their api
> consistent?

You could provide a fake object that just returns things as ->next is called
on it fairly trivially, but I'm not sure that's the ideal solution.

What sort of objects are ending up in @records? I wonder if you mightn't be
able to return a proper resultset for the query as of 0.05 unless it's a
really insane one :)

-- 
     Matt S Trout       Offering custom development, consultancy and support
  Technical Director    contracts for Catalyst, DBIx::Class and BAST. Contact
Shadowcat Systems Ltd.  mst (at) shadowcatsystems.co.uk for more information

 + Help us build a better perl ORM: http://dbix-class.shadowcatsystems.co.uk/ +



More information about the Dbix-class mailing list