My current Perl Ironman Challenge status is: My Ironman Badge

Thursday, January 7, 2010

More DBIC::API

I recently added a new feature to DBIC::API. You can now specify "as" as passed to ->search() that is a complement to the "select" attribute. This doesn't produce a true "as" because the DBIx::Class docs only say it is for internal access, but what it does produce is an accessor of that name (use get_column with specified "as"), to get at columns that are actually results produced from DB functions such as COUNT. This means you can specify:

?select.0.count=some_column&as.0=my_count

using CGI::Expand syntax to produce the right arguments to ->search

{ select => [ { count => 'some_column' } ], as => [ 'my_count ] }


This is rockin.

As funky as the CGI::Expand syntax is, it is incredibly flexible. This one minor feature let me avoid a more complicated setup for work and instead rely on what DBIC::API is good for: exposing DBIx::Class via web service.

I'll do another release of DBIC::API soon.

No comments:

Post a Comment