On Mon Mar 09 09:49:59 2009, TIMB wrote:
Show quoted text> I'd like _format_search() to be more granular. Specifically I'd like
> this line:
>
> my %search_params = map { ($base) ? join('.', $base, $_) : $_ =>
> $params->{$_} } grep { exists
> $params->{$_} } $source->columns;
>
> to become something like:
>
> my %search_params = $self->_map_search_params_to_condition($p);
>
> (I've given this wishlist severity, but I'd be grateful if it could
> get into a release soon.)
>
> I'd also like to see $c passed into _format_search and
> _map_search_params_to_condition,
> though that's less important.
>
i have a solution for this, but it is not exactly the one described here
since the _format_search method has changed since the last release and
is not quite so simple.
i believe that the problem you wanted to solve is to allow custom
parameters to be passed through so that you could latch on to them in
your resultset methods. currently this is not possible as anything that
is not a real column is ignored.
i have decided that i would like to achieve this by allowing the columns
that are valid to be configurable. this has the added advantage that
searchable columns can then also be restricted. for example:
package RestTest::Controller::API::RPC::TrackExposed;
...
__PACKAGE__->config
( ...,
list_search_exposes => [qw/position title custom_column/],
);
and then in your custom resultset:
package RestTest::Schema::ResultSet::Track;
use base 'RestTest::Schema::ResultSet';
sub search {
my $self = shift;
my ($clause, $params) = @_;
# test custom attrs
if (my $pretend = delete $clause->{custom_column}) {
$clause->{'cd.year'} = $pretend;
}
my $rs = $self->SUPER::search(@_);
}
This functionality is currently in svn*, so feel free to test. it will
be released as soon as ticket 44010 is resolved.
*
http://dev.catalystframework.org/repos/Catalyst/Catalyst-Controller-DBIC-API/