use Catalyst::Controller::DBIC::API::JoinBuilder;
-
=attribute_private search_validator
A Catalyst::Controller::DBIC::API::Validator instance used solely to validate search parameters
{
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))
foreach my $rel (@$new)
{
- $self->check_rel($rel, $p->static);
+ $self->_check_rel($rel, $p->static);
}
},
);
{
my ($self, $source, $param, $join, $base) = @_;
$base ||= 'me';
- my $search_params;
+ my $search_params = {};
# 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};
next;
}
- %$search_params =
- %{
+ $search_params = { %$search_params, %{
$self->generate_column_parameters
(
$source->related_source($column),
Catalyst::Controller::DBIC::API::JoinBuilder->new(parent => $join, name => $column),
$column
)
- };
+ }};
}
- 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;
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,
};