Fix the search bug #85

Merged
merged 1 commit into from Oct 15, 2015

Projects

None yet

2 participants

@yhbyun
Contributor
yhbyun commented Jul 1, 2015

If I search the tricks by test term, the following SQL is executed.

select count(*) as aggregate from `tricks` where `title` LIKE '%test%' or `description` LIKE '%test%' or
 (select count(*) from `tags` inner join `tag_trick` on `tags`.`id` = `tag_trick`.`tag_id` 
  where `tag_trick`.`trick_id` = `tricks`.`id` and `name` LIKE '%test%' or `slug` LIKE '%test%') >= 1 or 
 (select count(*) from `categories` inner join `category_trick` on `categories`.`id` = `category_trick`.`category_id` 
  where `category_trick`.`trick_id` = `tricks`.`id` and `name` LIKE '%test%' or `slug` LIKE '%test%') >= 1

Two parts of that SQL causes irrelevant result to the search term.

and `name` LIKE '%test%' or `slug` LIKE '%test%'
.
.
.
and `name` LIKE '%test%' or `slug` LIKE '%test%

I think that title only would be sufficient for search and in order to fix the above bug, I modified the code.

@yhbyun yhbyun changed the title from L to Fix the search bug Jul 1, 2015
@msurguy
Member
msurguy commented Oct 15, 2015

@yhbyun thanks for the PR! Is there an example on the website where it would return an incorrect result set? Thanks very much for trying to explain the issue!

@msurguy msurguy merged commit 29ce3f9 into CodepadME:master Oct 15, 2015
@msurguy
Member
msurguy commented Oct 15, 2015

Thanks! I've merged the PR and will try to update the site soon!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment