From edbb7df5057b42cd6416e9ef0a3ac614ed2e542b Mon Sep 17 00:00:00 2001
From: Dave Dash
Date: Wed, 18 Aug 2010 12:27:27 -0700
Subject: [PATCH] bug 587789, case insensitive guid search
---
apps/search/client.py | 4 ++--
apps/search/tests/test_client.py | 6 +++++-
configs/sphinx/sphinx.conf | 2 +-
3 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/apps/search/client.py b/apps/search/client.py
index 9f63511329..8779f8f884 100644
--- a/apps/search/client.py
+++ b/apps/search/client.py
@@ -95,14 +95,14 @@ def extract_filters(term, kwargs):
metas['type'] = addon_type
# Guid filtering..
- (term, guids) = extract_from_query(term, 'guid', '[{}@\.,\-0-9a-z]+',
+ (term, guids) = extract_from_query(term, 'guid', '[{}@\.,\-0-9a-zA-Z]+',
end_of_word_boundary=False)
if guids:
guids_crc = []
for guid in guids.split(','):
- guids_crc.append(crc32(guid))
+ guids_crc.append(crc32(guid.lower()))
filters['guid_ord'] = guids_crc
diff --git a/apps/search/tests/test_client.py b/apps/search/tests/test_client.py
index c5fb9a864a..52fcee2f26 100644
--- a/apps/search/tests/test_client.py
+++ b/apps/search/tests/test_client.py
@@ -128,7 +128,11 @@ class SearchTest(SphinxTestCase):
"""Filter by guid."""
eq_(query('guid:{4c197c8f-a50f-4b49-a2d2-ed922c95612f}')[0].id, 592)
- def test_guid_email_filter(self):
+ def test_guid_filter_uppercase(self):
+ """Filter by guids in whatever case I like."""
+ eq_(query('guid:{4C197C8F-A50F-4B49-A2D2-ED922C95612F}')[0].id, 592)
+
+ def test_guid_filter_email(self):
eq_(query('guid:yslow@yahoo-inc.com')[0].id, 5369)
def test_alpha_sort(self):
diff --git a/configs/sphinx/sphinx.conf b/configs/sphinx/sphinx.conf
index d2f107b8b2..a5e319c4c7 100755
--- a/configs/sphinx/sphinx.conf
+++ b/configs/sphinx/sphinx.conf
@@ -93,7 +93,7 @@ source addons
a.id AS addon_id, \
a.addontype_id AS type, \
a.status, \
- CRC32(a.guid) AS guid_ord, \
+ CRC32(LOWER(a.guid)) AS guid_ord, \
name.locale, \
CRC32(name.locale) AS locale_ord, \
a.bayesianrating AS averagerating, \