api/v0: make escaped sequences work for search
Reorder the regex chars and remove a needless escape while there.
This commit is contained in:
parent
202c6fa878
commit
29aa172391
1 changed files with 2 additions and 2 deletions
|
@ -81,7 +81,7 @@ sub search ($self)
|
||||||
status => 200
|
status => 200
|
||||||
) if $q eq "";
|
) if $q eq "";
|
||||||
|
|
||||||
$q =~ s/[\%_\\]/\\$&/g;
|
$q =~ s/[%\\_]/\\$&/g;
|
||||||
$q .= '%';
|
$q .= '%';
|
||||||
my %attrs = (
|
my %attrs = (
|
||||||
$search_opts{TagCountView}->%*,
|
$search_opts{TagCountView}->%*,
|
||||||
|
@ -95,7 +95,7 @@ sub search ($self)
|
||||||
display => $_->display,
|
display => $_->display,
|
||||||
count => $_->count,
|
count => $_->count,
|
||||||
}, $self->schema->resultset("TagCountView")
|
}, $self->schema->resultset("TagCountView")
|
||||||
->search({name => {-like => $q}}, \%attrs);
|
->search({name => \["LIKE ? ESCAPE '\\'", $q]}, \%attrs);
|
||||||
|
|
||||||
return $self->render(json => {tags => [@tags]});
|
return $self->render(json => {tags => [@tags]});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue