Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed error in search by people field #473

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions lib/GADS/Column/Person.pm
Original file line number Diff line number Diff line change
Expand Up @@ -211,4 +211,45 @@ sub import_value
});
}

sub values_beginning_with
{ my ($self, $match_string, %options) = @_;

my $resultset = $self->resultset_for_values;
my @value;
my $value_field = 'me.'.$self->value_field;
$match_string =~ s/([_%])/\\$1/g;
my $search = $match_string
? {
$value_field => {
-like => "${match_string}%",
},
}
: $options{noempty} && !$match_string
? { \"0 = 1" } # Nothing to match, return nothing
: {};
if ($resultset) {
my $match_result = $resultset->search($search,
{
rows => 10,
},
);
@value = map {
{
id => $_->get_column('id'),
label => $_->get_column($self->value_field),
}
} $match_result->search({}, {
select => [
{
max => 'me.id',
-as => 'id',
},
$value_field
],
group_by => [ $value_field, 'me.surname', 'me.firstname' ],
})->all;
}
return @value;
}

1;
Loading