X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Controller-DBIC-API.git;a=blobdiff_plain;f=lib%2FCatalyst%2FController%2FDBIC%2FAPI%2FRequestArguments.pm;h=e2b2775c8d7fc0f0b8c6a3f6a26096d161ae74a2;hp=a2fee74d0e21055987a1aa45aeaa483e28007a75;hb=8175463b4e1e7bb22f7f83f0eaa3e3a0ad1a70ea;hpb=b66d43106c928f395d6e0628f9f80b72a274b9d8 diff --git a/lib/Catalyst/Controller/DBIC/API/RequestArguments.pm b/lib/Catalyst/Controller/DBIC/API/RequestArguments.pm index a2fee74..e2b2775 100644 --- a/lib/Catalyst/Controller/DBIC/API/RequestArguments.pm +++ b/lib/Catalyst/Controller/DBIC/API/RequestArguments.pm @@ -10,8 +10,6 @@ use namespace::autoclean; use Catalyst::Controller::DBIC::API::JoinBuilder; -=for Pod::Coverage check_rel - =attribute_private search_validator A Catalyst::Controller::DBIC::API::Validator instance used solely to validate search parameters @@ -199,13 +197,13 @@ Like the synopsis in DBIC::API shows, you can declare a "template" of what is al { my ($self, $new) = @_; - sub check_rel { + sub _check_rel { my ($self, $rel, $static) = @_; if(ArrayRef->check($rel)) { foreach my $rel_sub (@$rel) { - $self->check_rel($rel_sub, $static); + $self->_check_rel($rel_sub, $static); } } elsif(HashRef->check($rel)) @@ -225,7 +223,7 @@ Like the synopsis in DBIC::API shows, you can declare a "template" of what is al foreach my $rel (@$new) { - $self->check_rel($rel, $p->static); + $self->_check_rel($rel, $p->static); } }, ); @@ -518,8 +516,9 @@ generate_column_parameters recursively generates properly aliased parameters for # build up condition foreach my $column (keys %$param) { - if($source->has_relationship($column)) + if ($source->has_relationship($column)) { + # check if the value isn't a hashref unless (ref($param->{$column}) && reftype($param->{$column}) eq 'HASH') { $search_params->{join('.', $base, $column)} = $param->{$column}; @@ -536,10 +535,22 @@ generate_column_parameters recursively generates properly aliased parameters for ) }}; } - else + elsif ($source->has_column($column)) { $search_params->{join('.', $base, $column)} = $param->{$column}; } + # might be a sql function instead of a column name + # e.g. {colname => {like => '%foo%'}} + else + { + # but only if it's not a hashref + unless (ref($param->{$column}) && reftype($param->{$column}) eq 'HASH') { + $search_params->{join('.', $base, $column)} = $param->{$column}; + } + else { + die "$column is neither a relationship nor a column\n"; + } + } } return $search_params; @@ -576,6 +587,7 @@ This builder method generates the search attributes as => $self->as || ((scalar(@{$static->as})) ? $static->as : undef), prefetch => $self->prefetch || $static->prefetch || undef, rows => $self->count || $static->count, + page => $static->page, offset => $self->offset, join => $self->build_joins, };