Skip to content

Fix the search bug #85

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

Merged
merged 1 commit into from
Oct 15, 2015
Merged

Fix the search bug #85

merged 1 commit into from
Oct 15, 2015

Conversation

yhbyun
Copy link
Contributor

@yhbyun 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 L Fix the search bug Jul 1, 2015
@msurguy
Copy link
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!

@yhbyun
Copy link
Contributor Author

yhbyun commented Oct 15, 2015

msurguy added a commit that referenced this pull request Oct 15, 2015
@msurguy msurguy merged commit 29ce3f9 into CodepadME:master Oct 15, 2015
@msurguy
Copy link
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
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants