use Catalyst::Controller::DBIC::API::JoinBuilder;
+=for Pod::Coverage check_rel
=attribute_private search_validator
parameter static => ( isa => Bool, default => 0 );
role {
-
+
my $p = shift;
-
+
if($p->static)
{
requires qw/check_has_relation check_column_relation/;
(
is => 'ro',
writer => '_set_prefetch',
- isa => Prefetch,
+ isa => Prefetch,
default => sub { $p->static ? [] : undef },
coerce => 1,
trigger => sub
(
is => 'ro',
writer => '_set_prefetch_allows',
- isa => ArrayRef[ArrayRef|Str|HashRef],
+ isa => ArrayRef[ArrayRef|Str|HashRef],
default => sub { [ ] },
predicate => 'has_prefetch_allows',
trigger => sub
trigger => sub
{
my ($self, $new) = @_;
-
+
if($self->has_search_exposes and @{$self->search_exposes})
{
foreach my $foo (@$new)
}
}
}
-
+
my ($search_parameters, $search_attributes) = $self->generate_parameters_attributes($new);
$self->_set_search_parameters($search_parameters);
$self->_set_search_attributes($search_attributes);
default => sub { $p->static ? [] : undef },
coerce => 1,
trigger => sub
- {
+ {
my ($self, $new) = @_;
if($self->has_select_exposes)
{
method format_search_parameters => sub
{
my ($self, $params) = @_;
-
+
my $genparams = [];
foreach my $param (@$params)
{
my ($self, $source, $param, $join, $base) = @_;
$base ||= 'me';
- my $search_params;
+ my $search_params = {};
# build up condition
foreach my $column (keys %$param)
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
{
{
my ($self, $args) = @_;
my $static = $self->_controller;
- my $search_attributes =
+ my $search_attributes =
{
group_by => $self->grouped_by || ((scalar(@{$static->grouped_by})) ? $static->grouped_by : undef),
order_by => $self->ordered_by || ((scalar(@{$static->ordered_by})) ? $static->ordered_by : undef),
$search_attributes->{page} = $search_attributes->{offset} / $search_attributes->{rows} + 1;
delete $search_attributes->{offset};
}
-
- $search_attributes =
- {
+
+ $search_attributes =
+ {
map { @$_ }
grep
{
- defined($_->[1])
- ?
+ defined($_->[1])
+ ?
(ref($_->[1]) && reftype($_->[1]) eq 'HASH' && keys %{$_->[1]})
|| (ref($_->[1]) && reftype($_->[1]) eq 'ARRAY' && @{$_->[1]})
|| length($_->[1])
if ($search_attributes->{page} && !$search_attributes->{rows}) {
die 'list_page can only be used with list_count';
}
-
+
if ($search_attributes->{select}) {
# make sure all columns have an alias to avoid ambiguous issues
# but allow non strings (eg. hashrefs for db procs like 'count')
}
return $search_attributes;
-
+
};
};