diff options
-rw-r--r-- | askbot/models/question.py | 2 | ||||
-rw-r--r-- | askbot/tests/db_api_tests.py | 8 |
2 files changed, 9 insertions, 1 deletions
diff --git a/askbot/models/question.py b/askbot/models/question.py index 6d25d5a6..797d1c84 100644 --- a/askbot/models/question.py +++ b/askbot/models/question.py @@ -139,7 +139,7 @@ class QuestionQuerySet(models.query.QuerySet): elif 'postgresql_psycopg2' in askbot.get_database_engine_name(): rank_clause = "ts_rank(question.text_search_vector, to_tsquery(%s))"; search_query = '&'.join(search_query.split()) - extra_params = ("'" + search_query + "'",) + extra_params = (search_query,) extra_kwargs = { 'select': {'relevance': rank_clause}, 'where': ['text_search_vector @@ to_tsquery(%s)'], diff --git a/askbot/tests/db_api_tests.py b/askbot/tests/db_api_tests.py index 66fb9f9d..6473845f 100644 --- a/askbot/tests/db_api_tests.py +++ b/askbot/tests/db_api_tests.py @@ -143,6 +143,14 @@ class DBApiTests(AskbotTestCase): count = models.Tag.objects.filter(name='one-tag').count() self.assertEquals(count, 0) + def test_search_with_apostrophe_works(self): + self.post_question( + user = self.user, + body_text = "ahahahahahahah database'" + ) + matches = models.Question.objects.get_by_text_query("database'") + self.assertTrue(len(matches) == 1) + class UserLikeTests(AskbotTestCase): def setUp(self): self.create_user() |