Skip Menu |

This queue is for tickets about the Catalyst-Controller-DBIC-API CPAN distribution.

Report information
The Basics
Id: 43964
Status: resolved
Priority: 0/
Queue: Catalyst-Controller-DBIC-API

People
Owner: Nobody in particular
Requestors: TIMB [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: 1.001000
Fixed in: (no value)



Subject: I'd like _format_search() to be more granular
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.
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/
Ideally I'd like to be able to allow patterns, like /^_.*_$/ so each class doesn't have to explicitly know what's possible, but I think what you have now would work for me. Thanks. p.s. The indentation is wacky in several places when viewed with standard tab stops (such as via a web browser, cat, less, printer etc etc :-)
On Wed Mar 18 10:43:02 2009, TIMB wrote: Show quoted text
> Ideally I'd like to be able to allow patterns, like /^_.*_$/ so each > class doesn't have to explicitly > know what's possible, but I think what you have now would work for me. > > Thanks. > > p.s. The indentation is wacky in several places when viewed with > standard tab stops (such as via > a web browser, cat, less, printer etc etc :-)
I have released the new list_search_exposes feature in 1.002000 which was shipped to CPAN yesterday: http://search.cpan.org/~lsaunders/Catalyst-Controller-DBIC-API-1.002000/lib/Catalyst/Controller/DBIC/API.pm#list_search_exposes Also you might consider providing the new setup_dbic_args_method which will allow you to mess with the generated $params, and $attrs before they are passed to $rs->search: http://search.cpan.org/~lsaunders/Catalyst-Controller-DBIC-API-1.002000/lib/Catalyst/Controller/DBIC/API.pm#setup_dbic_args_method