allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brond...@apache.org
Subject [17/38] git commit: [#4019] ticket:515 Don't escape the `q` query
Date Wed, 30 Apr 2014 18:15:49 GMT
[#4019] ticket:515 Don't escape the `q` query

Because it contains query provided by used which already in solr syntax
and could be escaped already.


Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/1d1c6c7b
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/1d1c6c7b
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/1d1c6c7b

Branch: refs/heads/master
Commit: 1d1c6c7b35a6d50f2fb792c9915775db95d8bbd6
Parents: 119b47a
Author: Igor Bondarenko <jetmind2@gmail.com>
Authored: Tue Jan 14 14:44:01 2014 +0200
Committer: Dave Brondsema <dbrondsema@slashdotmedia.com>
Committed: Wed Apr 30 15:55:11 2014 +0000

----------------------------------------------------------------------
 Allura/allura/model/artifact.py           | 12 +-----------
 Allura/allura/tests/unit/test_artifact.py |  9 ---------
 2 files changed, 1 insertion(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/1d1c6c7b/Allura/allura/model/artifact.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/artifact.py b/Allura/allura/model/artifact.py
index 5d28df3..07f4daf 100644
--- a/Allura/allura/model/artifact.py
+++ b/Allura/allura/model/artifact.py
@@ -32,7 +32,6 @@ from webhelpers import feedgenerator as FG
 from allura.lib import helpers as h
 from allura.lib import security
 
-from allura.lib.solr import escape_solr_arg
 from .session import main_orm_session
 from .session import project_orm_session
 
@@ -133,18 +132,9 @@ class Artifact(MappedClass):
     def translate_query(cls, q, fields):
         """Return a translated Solr query (``q``), where generic field
         identifiers are replaced by the 'strongly typed' versions defined in
-        ``fields``. Escape arguments
+        ``fields``.
 
         """
-        new_q = []
-        for part in q.split(' '):
-            if ':' in part:
-                field, val = part.split(':', 1)
-                new_q.append('%s:%s' % (field, escape_solr_arg(val)))
-            else:
-                new_q.append(escape_solr_arg(part))
-        q = ' '.join(new_q)
-
         for f in fields:
             if '_' in f:
                 base, typ = f.rsplit('_', 1)

http://git-wip-us.apache.org/repos/asf/allura/blob/1d1c6c7b/Allura/allura/tests/unit/test_artifact.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/unit/test_artifact.py b/Allura/allura/tests/unit/test_artifact.py
index 9f1bfd3..6e470c0 100644
--- a/Allura/allura/tests/unit/test_artifact.py
+++ b/Allura/allura/tests/unit/test_artifact.py
@@ -27,12 +27,3 @@ class TestArtifact(unittest.TestCase):
         query = 'foo:1 AND bar:2 AND foo_bar_baz:3'
         q = M.Artifact.translate_query(query, fields)
         self.assertEqual(q, 'foo_s:1 AND bar_ws:2 AND foo_bar_baz:3')
-
-        query = '!status:wont-fix OR !status:closed'
-        q = M.Artifact.translate_query(query, fields)
-        self.assertEqual(q, '!status:wont\-fix OR !status:closed')
-
-        query = '!status:wont-fix OR !status:closed AND _milestone::'
-        fields = ['_milestone_s']
-        q = M.Artifact.translate_query(query, fields)
-        self.assertEqual(q, '!status:wont\-fix OR !status:closed AND _milestone_s:\:')


Mime
View raw message