From b44cb5fe1d71976a6cbe3e56d60e6d81bdf7ef15 Mon Sep 17 00:00:00 2001 From: Tom Bloor Date: Tue, 25 Jul 2017 14:14:30 +0100 Subject: [PATCH] Fix issue with turning quote_names on with case insensitive search --- lib/Pear/LocalLoop.pm | 1 + lib/Pear/LocalLoop/Controller/Api/Upload.pm | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/Pear/LocalLoop.pm b/lib/Pear/LocalLoop.pm index 1c5efd6..b8b5756 100644 --- a/lib/Pear/LocalLoop.pm +++ b/lib/Pear/LocalLoop.pm @@ -14,6 +14,7 @@ has schema => sub { $c->app->config->{dsn}, $c->app->config->{user}, $c->app->config->{pass}, + { quote_names => 1 }, ); }; diff --git a/lib/Pear/LocalLoop/Controller/Api/Upload.pm b/lib/Pear/LocalLoop/Controller/Api/Upload.pm index 5d2eb0c..7953b7f 100644 --- a/lib/Pear/LocalLoop/Controller/Api/Upload.pm +++ b/lib/Pear/LocalLoop/Controller/Api/Upload.pm @@ -172,12 +172,14 @@ sub post_search { my $search_name = $validation->param('search_name'); + my $search_stmt = [ 'LOWER("name") LIKE ?', '%' . lc $search_name . '%' ]; + my $valid_orgs_rs = $c->schema->resultset('Organisation')->search( - { 'LOWER(name)' => { -like => '%' . lc $search_name . '%' } }, + \$search_stmt, ); my $pending_orgs_rs = $c->stash->{api_user}->pending_organisations->search( - { 'LOWER(name)' => { -like => '%' . lc $search_name . '%' } }, + \$search_stmt, ); my @valid_orgs = (