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=f490eedccddbcd58713434d5102672c17e0c4c3e;hb=11ba2ccc06f22b028f66fdfcad72ce3903345374;hpb=289747d9df08ca203600b181854c9085b1c12e2c diff --git a/lib/Catalyst/Controller/DBIC/API/RequestArguments.pm b/lib/Catalyst/Controller/DBIC/API/RequestArguments.pm index f490eed..e2b2775 100644 --- a/lib/Catalyst/Controller/DBIC/API/RequestArguments.pm +++ b/lib/Catalyst/Controller/DBIC/API/RequestArguments.pm @@ -516,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}; @@ -534,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;