Commit 59eb3b6c authored by Tristan Cavelier's avatar Tristan Cavelier

WIP

parent fe646921
......@@ -7456,7 +7456,7 @@ return new Parser;
function sanitizeQueryValue(value) {
if (typeof value === "string") {
return value.replace(/((?:\\\\)*)\\$/, "$1");
return value.replace(/((?:\\\\)*)\\$/, "$1").replace(/"/g, '\\"');
}
return value;
}
......
......@@ -57,7 +57,7 @@ class TestERP5Query(ERP5TypeTestCase):
self.portal.organisation_module.manage_delObjects(ids=[_id])
return self.portal.organisation_module.newContent(portal_type="Organisation", id=_id, **kw)
def _assertQueryKwParsingRenderingMatching(self, query_kw, expected_match_list=None):
def _assertQueryKwParsingRenderingMatching(self, query_kw, expected_match_list=None, XXX=False):
catalog = self.portal.portal_catalog
sql_catalog = catalog.getSQLCatalog()
parsed_query = sql_catalog.buildQuery(query_kw)
......@@ -66,7 +66,7 @@ class TestERP5Query(ERP5TypeTestCase):
parsed_query_2 = sql_catalog.buildQuery({"search_text": rendered_search_text})
generated_sql_2 = catalog(query=parsed_query_2, src__=1)
self.assertEqual(generated_sql, generated_sql_2, "{!r} != {!r}\n\ntraceback_info : {!r}".format(
self.assertEqual(XXX if XXX else generated_sql, generated_sql_2, "{!r} != {!r}\n\ntraceback_info : {!r}".format(
generated_sql,
generated_sql_2,
{
......@@ -230,11 +230,22 @@ class TestERP5Query(ERP5TypeTestCase):
# It actually matches [self.organisation_dict[k] for k in self.organisation_dict.keys() if k.startswith("01") or k.startswith("02")]) - should it really match "021" and "022" ? Behavior to be defined
@skip('please fix parse(render(parse(search_text_with_a_space))) != parse(search_text_with_a_space)')
def test_search_text_parsing_and_rendering_space(self):
def test_search_text_parsing_and_rendering_with_space(self):
self._assertQueryKwParsingRenderingMatching({'search_text': 'TestERP5QuerySpace AndText'})
def test_search_text_parsing_and_rendering_space_with_quote(self):
def test_search_text_parsing_and_rendering_with_space_and_quote(self):
self._assertQueryKwParsingRenderingMatching({'search_text': '"TestERP5QuerySpace AndText"'})
def test_search_text_parsing_and_rendering_with_column_and_equal(self): # XXX test it in ZSQLCatalog syntax tree check !
#self._assertQueryKwParsingRenderingMatching({'search_text': 'title:TestERP5QuerySpace"AndText'}, XXX=True) # <SimpleQuery 'SearchableText' mroonga_boolean 'title:TestERP5QuerySpace"AndText'>
#self._assertQueryKwParsingRenderingMatching({'search_text': 'title:TestERP5QuerySpace(AndText'}, XXX=True) # <SimpleQuery 'SearchableText' mroonga_boolean 'title:TestERP5QuerySpace(AndText'>
#self._assertQueryKwParsingRenderingMatching({'search_text': 'title:TestERP5QuerySpace)AndText'}, XXX=True) # <SimpleQuery 'SearchableText' mroonga_boolean 'title:TestERP5QuerySpace)AndText'>
#self._assertQueryKwParsingRenderingMatching({'search_text': 'title:TestERP5QuerySpace:AndText'}, XXX=True) # <SimpleQuery 'SearchableText' mroonga_boolean 'title:TestERP5QuerySpace:AndText'>
#self._assertQueryKwParsingRenderingMatching({'search_text': 'title:TestERP5QuerySpace>AndText'}, XXX=True) # <SimpleQuery 'title' = 'TestERP5QuerySpace>AndText'>
#self._assertQueryKwParsingRenderingMatching({'search_text': 'title:TestERP5QuerySpace<AndText'}, XXX=True) # <SimpleQuery 'title' = 'TestERP5QuerySpace<AndText'>
#self._assertQueryKwParsingRenderingMatching({'search_text': 'title:TestERP5QuerySpace!AndText'}, XXX=True) # <SimpleQuery 'title' = 'TestERP5QuerySpace!AndText'>
#self._assertQueryKwParsingRenderingMatching({'search_text': 'title:TestERP5QuerySpace=AndText'}, XXX=True) # <SimpleQuery 'title' = 'TestERP5QuerySpace=AndText'>
pass
def test_suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestERP5Query))
......
......@@ -279,7 +279,7 @@ if __name__ == '__main__':
query_list = [walk(x, key) for x in node.getNodeList()]
operator = node.getLogicalOperator()
if operator == 'not' or len(query_list) > 1:
result = ComplexQuery(query_list, logical_operator=logical_operator)
result = ComplexQuery(query_list, logical_operator=operator)
elif len(query_list) == 1:
result = query_list[0]
else:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment