Commit c9c8053b authored by Vincent Pelletier's avatar Vincent Pelletier

WIP all: Stop using ComplexQuery deprecated "operator" argument.

parent 77a1b9ce
...@@ -102,7 +102,7 @@ if request.get('omit_grouping_reference', False): ...@@ -102,7 +102,7 @@ if request.get('omit_grouping_reference', False):
params['grouping_query'] = ComplexQuery( params['grouping_query'] = ComplexQuery(
Query(grouping_reference=None), Query(grouping_reference=None),
Query(grouping_date=at_date, range="min"), Query(grouping_date=at_date, range="min"),
operator="OR") logical_operator="OR")
else: else:
params['grouping_reference'] = None params['grouping_reference'] = None
......
...@@ -17,7 +17,7 @@ inventory_query = { ...@@ -17,7 +17,7 @@ inventory_query = {
'grouping_query': ComplexQuery( 'grouping_query': ComplexQuery(
Query(grouping_reference=None), Query(grouping_reference=None),
Query(grouping_date=at_date, range="min"), Query(grouping_date=at_date, range="min"),
operator="OR"), logical_operator="OR"),
'simulation_state': params['simulation_state'], 'simulation_state': params['simulation_state'],
'node_uid': kw['node_uid'], 'node_uid': kw['node_uid'],
'portal_type': portal.getPortalAccountingMovementTypeList(), 'portal_type': portal.getPortalAccountingMovementTypeList(),
......
...@@ -15,7 +15,7 @@ section_uid = portal.Base_getSectionUidListForSectionCategory( ...@@ -15,7 +15,7 @@ section_uid = portal.Base_getSectionUidListForSectionCategory(
grouping_query = ComplexQuery( grouping_query = ComplexQuery(
Query(grouping_reference=None), Query(grouping_reference=None),
Query(grouping_date=at_date, range="min"), Query(grouping_date=at_date, range="min"),
operator="OR") logical_operator="OR")
account_number_memo = {} account_number_memo = {}
def getAccountNumber(account_url): def getAccountNumber(account_url):
......
...@@ -69,7 +69,7 @@ else: ...@@ -69,7 +69,7 @@ else:
if title: if title:
search_kw['title_query'] = ComplexQuery(Query(title=title), search_kw['title_query'] = ComplexQuery(Query(title=title),
Query(parent_title=title), Query(parent_title=title),
operator='OR') logical_operator='OR')
if delivery_reference: if delivery_reference:
search_kw['parent_reference'] = delivery_reference search_kw['parent_reference'] = delivery_reference
if debit_price: if debit_price:
......
...@@ -93,7 +93,7 @@ if portal.portal_selections.getSelectionParamsFor(selection_name).get('hide_grou ...@@ -93,7 +93,7 @@ if portal.portal_selections.getSelectionParamsFor(selection_name).get('hide_grou
params['grouping_query'] = ComplexQuery( params['grouping_query'] = ComplexQuery(
Query(grouping_reference=None), Query(grouping_reference=None),
Query(grouping_date=params['at_date'], range="min"), Query(grouping_date=params['at_date'], range="min"),
operator="OR") logical_operator="OR")
else: else:
params['grouping_reference'] = None params['grouping_reference'] = None
......
...@@ -11,5 +11,5 @@ return ComplexQuery( ...@@ -11,5 +11,5 @@ return ComplexQuery(
Query(validation_state=('published', 'published_alive', 'released', 'released_alive', 'shared', 'shared_alive'), Query(validation_state=('published', 'published_alive', 'released', 'released_alive', 'shared', 'shared_alive'),
reference='!=None'), reference='!=None'),
Query(validation_state='embedded', parent_uid=context.getUid()), Query(validation_state='embedded', parent_uid=context.getUid()),
operator='or'), logical_operator='or'),
operator='and') logical_operator='and')
...@@ -367,7 +367,7 @@ class JioGeneric(): ...@@ -367,7 +367,7 @@ class JioGeneric():
try: try:
while True: query_dict['query_list'].remove(None) while True: query_dict['query_list'].remove(None)
except ValueError: pass except ValueError: pass
return ComplexQuery(operator=query_dict['operator'], return ComplexQuery(logical_operator=query_dict['operator'],
*query_dict['query_list']) *query_dict['query_list'])
return None return None
return rec(query_dict) return rec(query_dict)
...@@ -380,7 +380,7 @@ class JioGeneric(): ...@@ -380,7 +380,7 @@ class JioGeneric():
kw['query'] = ComplexQuery( kw['query'] = ComplexQuery(
kw['query'], kw['query'],
ComplexQuery( ComplexQuery(
operator='or', logical_operator='or',
*[SimpleQuery(comparison_operator="=", portal_type=x) \ *[SimpleQuery(comparison_operator="=", portal_type=x) \
for x in self.allowed_portal_type_list] for x in self.allowed_portal_type_list]
), ),
...@@ -388,7 +388,7 @@ class JioGeneric(): ...@@ -388,7 +388,7 @@ class JioGeneric():
) )
else: else:
kw['query'] = ComplexQuery( kw['query'] = ComplexQuery(
operator='or', logical_operator='or',
*[SimpleQuery(comparison_operator="=", portal_type=x) \ *[SimpleQuery(comparison_operator="=", portal_type=x) \
for x in self.allowed_portal_type_list] for x in self.allowed_portal_type_list]
) )
...@@ -438,7 +438,7 @@ class JioGeneric(): ...@@ -438,7 +438,7 @@ class JioGeneric():
# editkw['query'] = ComplexQuery( # editkw['query'] = ComplexQuery(
# editkw['query'], # editkw['query'],
# ComplexQuery( # ComplexQuery(
# operator='or', # logical_operator='or',
# *[SimpleQuery(comparison_operator="=", portal_type=x) \ # *[SimpleQuery(comparison_operator="=", portal_type=x) \
# for x in self.allowed_portal_type_list] # for x in self.allowed_portal_type_list]
# ), # ),
......
...@@ -30,7 +30,7 @@ for action in ordered_global_action_list: ...@@ -30,7 +30,7 @@ for action in ordered_global_action_list:
sub_query_list = [] sub_query_list = []
for k, v in query_dict.items(): for k, v in query_dict.items():
sub_query_list.append(Query(**{k: v})) sub_query_list.append(Query(**{k: v}))
complex_query = ComplexQuery(*sub_query_list, **dict(operator="AND")) complex_query = ComplexQuery(logical_operator="AND", *sub_query_list)
# add to query filtering by local roles as defined in worklist # add to query filtering by local roles as defined in worklist
complex_query = portal.portal_catalog.getSecurityQuery(query=complex_query, local_roles=local_roles) complex_query = portal.portal_catalog.getSecurityQuery(query=complex_query, local_roles=local_roles)
query_list.append(complex_query) query_list.append(complex_query)
...@@ -43,7 +43,7 @@ if not query_list: ...@@ -43,7 +43,7 @@ if not query_list:
return [] return []
# Invoke catalog # Invoke catalog
query = ComplexQuery(*query_list, **dict(operator="OR")) query = ComplexQuery(logical_operator="OR", *query_list)
#query = portal.portal_catalog.getSecurityQuery(query) #query = portal.portal_catalog.getSecurityQuery(query)
#result_list = portal.portal_catalog(query=query, #result_list = portal.portal_catalog(query=query,
# sort_on='modification_date', # sort_on='modification_date',
......
...@@ -18,7 +18,7 @@ for base_category_name, category in category_dict.items(): ...@@ -18,7 +18,7 @@ for base_category_name, category in category_dict.items():
key='ExactMatch'), key='ExactMatch'),
Query(reference=category, Query(reference=category,
key='ExactMatch'), key='ExactMatch'),
operator='OR'), logical_operator='OR'),
ComplexQuery(Query(relative_url='%s/%%' % base_category_name))) ComplexQuery(Query(relative_url='%s/%%' % base_category_name)))
category_value = portal.portal_catalog.getResultValue(query=query) category_value = portal.portal_catalog.getResultValue(query=query)
......
...@@ -11,7 +11,7 @@ catalog_kw = {'query': ComplexQuery(Query(start_date=">=%s" % from_date.strftime ...@@ -11,7 +11,7 @@ catalog_kw = {'query': ComplexQuery(Query(start_date=">=%s" % from_date.strftime
Query(stop_date="<=%s" % to_date.strftime("%Y/%m/%d")), Query(stop_date="<=%s" % to_date.strftime("%Y/%m/%d")),
Query(destination_trade_uid=Query(destination_trade_uid=destination_trade.getUid())), Query(destination_trade_uid=Query(destination_trade_uid=destination_trade.getUid())),
Query(simulation_state='!=cancelled'), Query(simulation_state='!=cancelled'),
operator="AND")} logical_operator="AND")}
paysheet_list = portal.accounting_module.searchFolder(portal_type="Pay Sheet Transaction", **catalog_kw) paysheet_list = portal.accounting_module.searchFolder(portal_type="Pay Sheet Transaction", **catalog_kw)
......
...@@ -19,7 +19,7 @@ query = ComplexQuery(Query(parent_uid=event_uid_list), ...@@ -19,7 +19,7 @@ query = ComplexQuery(Query(parent_uid=event_uid_list),
Query(uid=event_uid_list), Query(uid=event_uid_list),
Query(parent_uid=attachment_pdf_uid_list), Query(parent_uid=attachment_pdf_uid_list),
Query(uid=attachment_pdf_uid_list), Query(uid=attachment_pdf_uid_list),
operator="OR") logical_operator="OR")
kw['portal_type'] = ('PDF','Image') + context.getPortalDocumentTypeList()+context.getPortalEventTypeList() kw['portal_type'] = ('PDF','Image') + context.getPortalDocumentTypeList()+context.getPortalEventTypeList()
return context.portal_catalog(query=query, **kw) return context.portal_catalog(query=query, **kw)
...@@ -19,7 +19,7 @@ query = ComplexQuery(Query(parent_uid=event_uid_list), ...@@ -19,7 +19,7 @@ query = ComplexQuery(Query(parent_uid=event_uid_list),
Query(uid=event_uid_list), Query(uid=event_uid_list),
Query(parent_uid=attachment_pdf_uid_list), Query(parent_uid=attachment_pdf_uid_list),
Query(uid=attachment_pdf_uid_list), Query(uid=attachment_pdf_uid_list),
operator="OR") logical_operator="OR")
kw['portal_type'] = ('PDF') kw['portal_type'] = ('PDF')
......
...@@ -30,7 +30,7 @@ query = ComplexQuery(Query(parent_uid=event_uid_list), ...@@ -30,7 +30,7 @@ query = ComplexQuery(Query(parent_uid=event_uid_list),
Query(uid=event_uid_list), Query(uid=event_uid_list),
Query(parent_uid=attachment_pdf_uid_list), Query(parent_uid=attachment_pdf_uid_list),
Query(uid=attachment_pdf_uid_list), Query(uid=attachment_pdf_uid_list),
operator="OR") logical_operator="OR")
kw['portal_type'] = ('PDF') kw['portal_type'] = ('PDF')
result_uid = [x.getUid() for x in context.portal_catalog(query=query, **kw)] result_uid = [x.getUid() for x in context.portal_catalog(query=query, **kw)]
......
...@@ -48,7 +48,7 @@ for item in items: ...@@ -48,7 +48,7 @@ for item in items:
# query = ComplexQuery(Query(title=person_title), # query = ComplexQuery(Query(title=person_title),
# Query(birth_date=item['start_date']), # Query(birth_date=item['start_date']),
# Query(birthplace_city=item['default_birthplace_address_city']), # Query(birthplace_city=item['default_birthplace_address_city']),
# operator="AND") # logical_operator="AND")
# best_candidate_list=list(context.portal_catalog(portal_type='Person', # best_candidate_list=list(context.portal_catalog(portal_type='Person',
# query=query)) # query=query))
#verify that the new person is not selected more than once in the fast input #verify that the new person is not selected more than once in the fast input
......
...@@ -46,7 +46,7 @@ for item in items: ...@@ -46,7 +46,7 @@ for item in items:
# query = ComplexQuery(Query(title=person_title), # query = ComplexQuery(Query(title=person_title),
# Query(birth_date=item['start_date']), # Query(birth_date=item['start_date']),
# Query(birthplace_city=item['default_birthplace_address_city']), # Query(birthplace_city=item['default_birthplace_address_city']),
# operator="AND") # logical_operator="AND")
# best_candidate_list=list(context.portal_catalog(portal_type='Person', # best_candidate_list=list(context.portal_catalog(portal_type='Person',
# query=query)) # query=query))
#verify that the new person is not selected more than once in the fast input #verify that the new person is not selected more than once in the fast input
......
...@@ -54,31 +54,31 @@ if person_start_date == None or person_birthplace == None: ...@@ -54,31 +54,31 @@ if person_start_date == None or person_birthplace == None:
Query(title = person_title_reversed), Query(title = person_title_reversed),
Query(title = person_first_name), Query(title = person_first_name),
Query(title = person_last_name), Query(title = person_last_name),
operator = "OR") logical_operator = "OR")
else: else:
query = ComplexQuery(Query(title = person_title), query = ComplexQuery(Query(title = person_title),
ComplexQuery( ComplexQuery(
Query(title = person_title), Query(title = person_title),
Query(birth_date = person_start_date), Query(birth_date = person_start_date),
operator = "AND"), logical_operator = "AND"),
ComplexQuery( ComplexQuery(
Query(title = person_title), Query(title = person_title),
Query(birthplace_city = person_birthplace), Query(birthplace_city = person_birthplace),
operator = "AND"), logical_operator = "AND"),
ComplexQuery( ComplexQuery(
Query(birth_date = person_start_date), Query(birth_date = person_start_date),
Query(birthplace_city = person_birthplace), Query(birthplace_city = person_birthplace),
operator = "AND"), logical_operator = "AND"),
ComplexQuery( ComplexQuery(
Query(title = person_title_reversed), Query(title = person_title_reversed),
Query(title = person_first_name), Query(title = person_first_name),
Query(title = person_last_name), Query(title = person_last_name),
operator = "OR"), logical_operator = "OR"),
ComplexQuery( ComplexQuery(
Query(title = person_title), Query(title = person_title),
Query(birth_date = [DateTime(person_start_date.year(), 1, 1), DateTime(person_start_date.year(), 12, 31),],range = 'minmax'), Query(birth_date = [DateTime(person_start_date.year(), 1, 1), DateTime(person_start_date.year(), 12, 31),],range = 'minmax'),
operator = "AND"), logical_operator = "AND"),
operator = "OR") logical_operator = "OR")
#select_expression = \ #select_expression = \
#"""((title ="%s") + (start_date ="%s") + (birthplace_city ="%s"))AS result_order #"""((title ="%s") + (start_date ="%s") + (birthplace_city ="%s"))AS result_order
#""" % (person_title, person_start_date, person_birthplace) #""" % (person_title, person_start_date, person_birthplace)
......
...@@ -79,7 +79,7 @@ new_registry_number = request_eform.portal_ids.generateNewId( ...@@ -79,7 +79,7 @@ new_registry_number = request_eform.portal_ids.generateNewId(
query=ComplexQuery(Query(title=request_eform.getTitle()), query=ComplexQuery(Query(title=request_eform.getTitle()),
Query(birth_date=request_eform.getStartDate()), Query(birth_date=request_eform.getStartDate()),
Query(birthplace_city=request_eform.getDefaultBirthplaceAddressCity()), Query(birthplace_city=request_eform.getDefaultBirthplaceAddressCity()),
operator="AND") logical_operator="AND")
person_list = [person.getObject() for person in person_module.searchFolder(query=query)] person_list = [person.getObject() for person in person_module.searchFolder(query=query)]
if request_eform.getBeginning() or request_eform.getOpening(): if request_eform.getBeginning() or request_eform.getOpening():
if len(person_list) == 0: if len(person_list) == 0:
......
...@@ -49,7 +49,7 @@ request_eform.setTitle(request_eform.getOwnerFirstName()+' '+request_eform.getOw ...@@ -49,7 +49,7 @@ request_eform.setTitle(request_eform.getOwnerFirstName()+' '+request_eform.getOw
query=ComplexQuery(Query(title=request_eform.getTitle()), query=ComplexQuery(Query(title=request_eform.getTitle()),
Query(birth_date=request_eform.getOwnerBirthday()), Query(birth_date=request_eform.getOwnerBirthday()),
Query(birthplace_city=request_eform.getOwnerBirthplace()), Query(birthplace_city=request_eform.getOwnerBirthplace()),
operator="AND") logical_operator="AND")
person_list=[person.getObject() for person in \ person_list=[person.getObject() for person in \
context.portal_catalog(portal_type='Person',query=query)] context.portal_catalog(portal_type='Person',query=query)]
......
...@@ -16,11 +16,11 @@ new_test_result_list = [] ...@@ -16,11 +16,11 @@ new_test_result_list = []
context.log("rev_query_list", rev_query_list) context.log("rev_query_list", rev_query_list)
if rev_query_list: if rev_query_list:
result = context.searchFolder(title='PERF-ERP5-MASTER', simulation_state='stopped', result = context.searchFolder(title='PERF-ERP5-MASTER', simulation_state='stopped',
revision=ComplexQuery(operator='AND', *rev_query_list), revision=ComplexQuery(logical_operator='AND', *rev_query_list),
sort_on=(('delivery.start_date', 'ASC'),),src__=1) sort_on=(('delivery.start_date', 'ASC'),),src__=1)
context.log("result", result) context.log("result", result)
for test in context.searchFolder(title='PERF-ERP5-MASTER', simulation_state='stopped', for test in context.searchFolder(title='PERF-ERP5-MASTER', simulation_state='stopped',
revision=ComplexQuery(operator='AND', *rev_query_list), revision=ComplexQuery(logical_operator='AND', *rev_query_list),
sort_on=(('delivery.start_date', 'ASC'),)): sort_on=(('delivery.start_date', 'ASC'),)):
test = test.getObject() test = test.getObject()
if revision != test.getReference(): if revision != test.getReference():
......
...@@ -204,7 +204,7 @@ class NodeBudgetVariation(BudgetVariation): ...@@ -204,7 +204,7 @@ class NodeBudgetVariation(BudgetVariation):
query = ComplexQuery( query = ComplexQuery(
NegatedQuery(Query(**{axis: other_uid_list})), NegatedQuery(Query(**{axis: other_uid_list})),
Query(**{axis: None}), Query(**{axis: None}),
operator="OR") logical_operator="OR")
else: else:
value = portal_categories.getCategoryValue(node_url, value = portal_categories.getCategoryValue(node_url,
...@@ -219,7 +219,7 @@ class NodeBudgetVariation(BudgetVariation): ...@@ -219,7 +219,7 @@ class NodeBudgetVariation(BudgetVariation):
query_dict[axis] = ComplexQuery( query_dict[axis] = ComplexQuery(
query, query,
Query(**{axis: query_dict[axis]}), Query(**{axis: query_dict[axis]}),
operator='OR') logical_operator='OR')
else: else:
query_dict[axis] = query query_dict[axis] = query
...@@ -297,7 +297,7 @@ class NodeBudgetVariation(BudgetVariation): ...@@ -297,7 +297,7 @@ class NodeBudgetVariation(BudgetVariation):
query_dict[axis] = ComplexQuery( query_dict[axis] = ComplexQuery(
Query(**{axis: None}), Query(**{axis: None}),
Query(**{axis: query_dict[axis]}), Query(**{axis: query_dict[axis]}),
operator="OR") logical_operator="OR")
else: else:
query_dict[axis] = Query(**{axis: None}) query_dict[axis] = Query(**{axis: None})
return query_dict return query_dict
......
...@@ -246,7 +246,7 @@ class SimulationTool(BaseTool): ...@@ -246,7 +246,7 @@ class SimulationTool(BaseTool):
simulation_query = ComplexQuery( simulation_query = ComplexQuery(
self._getIncreaseQuery(table, 'quantity', True), self._getIncreaseQuery(table, 'quantity', True),
SimpleQuery(**{table + '.simulation_state': input_simulation_state}), SimpleQuery(**{table + '.simulation_state': input_simulation_state}),
operator='AND', logical_operator='AND',
) )
output_simulation_state = simulation_state_dict.get('output_simulation_state') output_simulation_state = simulation_state_dict.get('output_simulation_state')
if output_simulation_state is not None: if output_simulation_state is not None:
...@@ -255,9 +255,9 @@ class SimulationTool(BaseTool): ...@@ -255,9 +255,9 @@ class SimulationTool(BaseTool):
ComplexQuery( ComplexQuery(
self._getIncreaseQuery(table, 'quantity', False), self._getIncreaseQuery(table, 'quantity', False),
SimpleQuery(**{table + '.simulation_state': output_simulation_state}), SimpleQuery(**{table + '.simulation_state': output_simulation_state}),
operator='AND', logical_operator='AND',
), ),
operator='OR' logical_operator='OR'
) )
return simulation_query return simulation_query
...@@ -378,14 +378,14 @@ class SimulationTool(BaseTool): ...@@ -378,14 +378,14 @@ class SimulationTool(BaseTool):
ComplexQuery( ComplexQuery(
SimpleQuery(comparison_operator='<', **{table + '.' + column: 0}), SimpleQuery(comparison_operator='<', **{table + '.' + column: 0}),
SimpleQuery(**{table + '.is_cancellation': increase}), SimpleQuery(**{table + '.is_cancellation': increase}),
operator='AND', logical_operator='AND',
), ),
ComplexQuery( ComplexQuery(
SimpleQuery(comparison_operator='>=', **{table + '.' + column: 0}), SimpleQuery(comparison_operator='>=', **{table + '.' + column: 0}),
SimpleQuery(**{table + '.is_cancellation': not increase}), SimpleQuery(**{table + '.is_cancellation': not increase}),
operator='AND', logical_operator='AND',
), ),
operator='OR', logical_operator='OR',
) )
def _generateSQLKeywordDict(self, table='stock', **kw): def _generateSQLKeywordDict(self, table='stock', **kw):
...@@ -491,7 +491,7 @@ class SimulationTool(BaseTool): ...@@ -491,7 +491,7 @@ class SimulationTool(BaseTool):
simulation_query = ComplexQuery( simulation_query = ComplexQuery(
simulation_query, simulation_query,
reserved_query, reserved_query,
operator='OR', logical_operator='OR',
) )
if simulation_query is not None: if simulation_query is not None:
new_kw['query'] = simulation_query new_kw['query'] = simulation_query
......
...@@ -11,6 +11,6 @@ if follow_up_related_document_list: ...@@ -11,6 +11,6 @@ if follow_up_related_document_list:
kw['query'] = ComplexQuery( kw['query'] = ComplexQuery(
kw['query'], kw['query'],
Query(uid=[x.getUid() for x in follow_up_related_document_list]), Query(uid=[x.getUid() for x in follow_up_related_document_list]),
operator='or') logical_operator='or')
return portal_catalog(portal_type=portal_type, limit=limit, **kw) return portal_catalog(portal_type=portal_type, limit=limit, **kw)
...@@ -61,7 +61,7 @@ for key in sorted(request.form.keys()): ...@@ -61,7 +61,7 @@ for key in sorted(request.form.keys()):
q_kw = {key : None} q_kw = {key : None}
left_join_list.append(key) left_join_list.append(key)
left_join_list.append('strict_%s' % key) left_join_list.append('strict_%s' % key)
query_list.append(ComplexQuery(NegatedQuery(Query(**nq_kw)), Query(**q_kw), operator="OR")) query_list.append(ComplexQuery(NegatedQuery(Query(**nq_kw)), Query(**q_kw), logical_operator="OR"))
new_mapping[key] = "" new_mapping[key] = ""
new_mapping["dialog_%s" %(key,)] = value new_mapping["dialog_%s" %(key,)] = value
new_mapping["dialog_excluded_%s" %(key,)] = True new_mapping["dialog_excluded_%s" %(key,)] = True
......
...@@ -6,5 +6,5 @@ from Products.ZSQLCatalog.SQLCatalog import Query ...@@ -6,5 +6,5 @@ from Products.ZSQLCatalog.SQLCatalog import Query
query = ComplexQuery(Query(title=value), query = ComplexQuery(Query(title=value),
Query(reference=value), Query(reference=value),
operator="OR") logical_operator="OR")
return query return query
...@@ -619,8 +619,7 @@ class CatalogTool (UniqueObject, ZCatalog, CMFCoreCatalogTool, ActiveObject): ...@@ -619,8 +619,7 @@ class CatalogTool (UniqueObject, ZCatalog, CMFCoreCatalogTool, ActiveObject):
for key, value in role_column_dict.items(): for key, value in role_column_dict.items():
new_query = Query(**{key : value}) new_query = Query(**{key : value})
query_list.append(new_query) query_list.append(new_query)
operator_kw = {'operator': 'OR'} role_query = ComplexQuery(logical_operator='OR', *query_list)
role_query = ComplexQuery(*query_list, **operator_kw)
if security_uid_dict: if security_uid_dict:
catalog_security_uid_groups_columns_dict = \ catalog_security_uid_groups_columns_dict = \
self.getSQLCatalog().getSQLCatalogSecurityUidGroupsColumnsDict() self.getSQLCatalog().getSQLCatalogSecurityUidGroupsColumnsDict()
...@@ -634,12 +633,12 @@ class CatalogTool (UniqueObject, ZCatalog, CMFCoreCatalogTool, ActiveObject): ...@@ -634,12 +633,12 @@ class CatalogTool (UniqueObject, ZCatalog, CMFCoreCatalogTool, ActiveObject):
security_uid_list, security_uid_list,
'operator': 'IN'})) 'operator': 'IN'}))
security_uid_query = ComplexQuery(*query_list, operator='OR') security_uid_query = ComplexQuery(*query_list, logical_operator='OR')
if role_query: if role_query:
if security_uid_query: if security_uid_query:
# merge # merge
query = ComplexQuery(security_uid_query, role_query, operator='OR') query = ComplexQuery(security_uid_query, role_query, logical_operator='OR')
else: else:
query = role_query query = role_query
elif security_uid_query: elif security_uid_query:
...@@ -659,9 +658,8 @@ class CatalogTool (UniqueObject, ZCatalog, CMFCoreCatalogTool, ActiveObject): ...@@ -659,9 +658,8 @@ class CatalogTool (UniqueObject, ZCatalog, CMFCoreCatalogTool, ActiveObject):
for key, value in local_role_column_dict.items(): for key, value in local_role_column_dict.items():
new_query = Query(**{key : value}) new_query = Query(**{key : value})
query_list.append(new_query) query_list.append(new_query)
operator_kw = {'operator': 'AND'} local_role_query = ComplexQuery(logical_operator='AND', *query_list)
local_role_query = ComplexQuery(*query_list, **operator_kw) query = ComplexQuery(query, local_role_query, logical_operator='AND')
query = ComplexQuery(query, local_role_query, operator='AND')
return query return query
......
...@@ -1213,7 +1213,7 @@ class TestERP5Catalog(ERP5TypeTestCase, LogInterceptor): ...@@ -1213,7 +1213,7 @@ class TestERP5Catalog(ERP5TypeTestCase, LogInterceptor):
# title='bcd' OR description='efg' # title='bcd' OR description='efg'
catalog_kw = {'query':ComplexQuery(Query(title='bcd'), catalog_kw = {'query':ComplexQuery(Query(title='bcd'),
Query(description='efg'), Query(description='efg'),
operator='OR')} logical_operator='OR')}
self.failIfDifferentSet([org_b.getPath(), org_c.getPath()], self.failIfDifferentSet([org_b.getPath(), org_c.getPath()],
[x.path for x in self.getCatalogTool()( [x.path for x in self.getCatalogTool()(
portal_type='Organisation',**catalog_kw)]) portal_type='Organisation',**catalog_kw)])
...@@ -1222,11 +1222,11 @@ class TestERP5Catalog(ERP5TypeTestCase, LogInterceptor): ...@@ -1222,11 +1222,11 @@ class TestERP5Catalog(ERP5TypeTestCase, LogInterceptor):
# title='foo' and description='bar' # title='foo' and description='bar'
catalog_kw = {'query':ComplexQuery(ComplexQuery(SimpleQuery(title='abc'), catalog_kw = {'query':ComplexQuery(ComplexQuery(SimpleQuery(title='abc'),
SimpleQuery(description='abc'), SimpleQuery(description='abc'),
operator='AND'), logical_operator='AND'),
ComplexQuery(SimpleQuery(title='foo'), ComplexQuery(SimpleQuery(title='foo'),
SimpleQuery(description='bar'), SimpleQuery(description='bar'),
operator='AND'), logical_operator='AND'),
operator='OR')} logical_operator='OR')}
self.failIfDifferentSet([org_a.getPath(), org_f.getPath()], self.failIfDifferentSet([org_a.getPath(), org_f.getPath()],
[x.path for x in self.getCatalogTool()( [x.path for x in self.getCatalogTool()(
portal_type='Organisation',**catalog_kw)]) portal_type='Organisation',**catalog_kw)])
...@@ -1719,7 +1719,7 @@ class TestERP5Catalog(ERP5TypeTestCase, LogInterceptor): ...@@ -1719,7 +1719,7 @@ class TestERP5Catalog(ERP5TypeTestCase, LogInterceptor):
# First try without aliases # First try without aliases
query1 = Query(parent_portal_type="Organisation") query1 = Query(parent_portal_type="Organisation")
query2 = Query(grand_parent_portal_type="Organisation Module") query2 = Query(grand_parent_portal_type="Organisation Module")
complex_query = ComplexQuery(query1, query2, operator="AND") complex_query = ComplexQuery(query1, query2, logical_operator="AND")
self.failIfDifferentSet([org_a.getPath() + '/default_address'], self.failIfDifferentSet([org_a.getPath() + '/default_address'],
[x.path for x in self.getCatalogTool()(query=complex_query)]) [x.path for x in self.getCatalogTool()(query=complex_query)])
# Then try with aliases # Then try with aliases
...@@ -1728,7 +1728,7 @@ class TestERP5Catalog(ERP5TypeTestCase, LogInterceptor): ...@@ -1728,7 +1728,7 @@ class TestERP5Catalog(ERP5TypeTestCase, LogInterceptor):
query2 = Query(grand_parent_portal_type="Organisation Module", query2 = Query(grand_parent_portal_type="Organisation Module",
table_alias_list=(("catalog" , "parent"), table_alias_list=(("catalog" , "parent"),
("catalog", "grand_parent"))) ("catalog", "grand_parent")))
complex_query = ComplexQuery(query1, query2, operator="AND") complex_query = ComplexQuery(query1, query2, logical_operator="AND")
self.failIfDifferentSet([org_a.getPath() + '/default_address'], self.failIfDifferentSet([org_a.getPath() + '/default_address'],
[x.path for x in self.getCatalogTool()(query=complex_query)]) [x.path for x in self.getCatalogTool()(query=complex_query)])
sql_kw = self.getCatalogTool().buildSQLQuery(query=complex_query) sql_kw = self.getCatalogTool().buildSQLQuery(query=complex_query)
...@@ -2180,27 +2180,27 @@ class TestERP5Catalog(ERP5TypeTestCase, LogInterceptor): ...@@ -2180,27 +2180,27 @@ class TestERP5Catalog(ERP5TypeTestCase, LogInterceptor):
# complex query # complex query
query = ComplexQuery(Query(portal_type='Person'), query = ComplexQuery(Query(portal_type='Person'),
Query(region_uid=asia.getUid()), Query(region_uid=asia.getUid()),
operator='AND') logical_operator='AND')
self.assertEqual(len(catalog(query=query)), 1) self.assertEqual(len(catalog(query=query)), 1)
# complex query # complex query
query = ComplexQuery(Query(portal_type='Person'), query = ComplexQuery(Query(portal_type='Person'),
Query(region_uid=(africa.getUid(), asia.getUid())), Query(region_uid=(africa.getUid(), asia.getUid())),
operator='AND') logical_operator='AND')
self.assertEqual(len(catalog(query=query)), 2) self.assertEqual(len(catalog(query=query)), 2)
# more complex query # more complex query
query_find_european = ComplexQuery(Query(portal_type='Person'), query_find_european = ComplexQuery(Query(portal_type='Person'),
Query(region_uid=europe.getUid()), Query(region_uid=europe.getUid()),
operator='AND') logical_operator='AND')
self.assertEqual(len(catalog(query=query_find_european)), 1) self.assertEqual(len(catalog(query=query_find_european)), 1)
query_find_name_erp5 = ComplexQuery(Query(portal_type='Person'), query_find_name_erp5 = ComplexQuery(Query(portal_type='Person'),
Query(title='%ERP5'), Query(title='%ERP5'),
operator='AND') logical_operator='AND')
self.assertEqual(len(catalog(query=query_find_name_erp5)), 2) self.assertEqual(len(catalog(query=query_find_name_erp5)), 2)
self.assertRaises(NotImplementedError, ComplexQuery, query_find_european, query_find_name_erp5, operator='OR') self.assertRaises(NotImplementedError, ComplexQuery, query_find_european, query_find_name_erp5, logical_operator='OR')
def test_check_security_table_content(self): def test_check_security_table_content(self):
sql_connection = self.getSQLConnection() sql_connection = self.getSQLConnection()
...@@ -3525,19 +3525,19 @@ VALUES ...@@ -3525,19 +3525,19 @@ VALUES
'site_reference="foo" AND function_description="bar"', 'site_reference="foo" AND function_description="bar"',
ComplexQuery(Query(site_reference='foo'), ComplexQuery(Query(site_reference='foo'),
Query(function_description='bar'), Query(function_description='bar'),
operator='AND')) logical_operator='AND'))
# Double join on same relation # Double join on same relation
check(both_object_list, check(both_object_list,
'site_reference="foo" AND site_description="bar"', 'site_reference="foo" AND site_description="bar"',
ComplexQuery(Query(site_reference='foo'), ComplexQuery(Query(site_reference='foo'),
Query(site_description='bar'), Query(site_description='bar'),
operator='AND')) logical_operator='AND'))
# Double join on same related key # Double join on same related key
check(title_object_list, check(title_object_list,
'site_title="foo1" AND site_title="foo2"', 'site_title="foo1" AND site_title="foo2"',
ComplexQuery(Query(site_title='=foo1'), ComplexQuery(Query(site_title='=foo1'),
Query(site_title='=foo2'), Query(site_title='=foo2'),
operator='AND')) logical_operator='AND'))
def test_SearchFolderWithRelatedDynamicRelatedKey(self): def test_SearchFolderWithRelatedDynamicRelatedKey(self):
# Create some objects # Create some objects
......
...@@ -282,9 +282,9 @@ def generateNestedQuery(getQuery, priority_list, criterion_dict, ...@@ -282,9 +282,9 @@ def generateNestedQuery(getQuery, priority_list, criterion_dict,
**{my_criterion_id: criterion_value}) **{my_criterion_id: criterion_value})
if isinstance(criterion_value, ExclusionTuple): if isinstance(criterion_value, ExclusionTuple):
query = NegatedQuery(query) query = NegatedQuery(query)
query = ComplexQuery(operator='OR', query = ComplexQuery(logical_operator='OR',
*(query, getQuery(**{my_criterion_id: None}))) *(query, getQuery(**{my_criterion_id: None})))
append(ComplexQuery(query, subcriterion_query, operator='AND')) append(ComplexQuery(query, subcriterion_query, logical_operator='AND'))
else: else:
possible_value_list = tuple() possible_value_list = tuple()
impossible_value_list = tuple() impossible_value_list = tuple()
...@@ -315,12 +315,12 @@ def generateNestedQuery(getQuery, priority_list, criterion_dict, ...@@ -315,12 +315,12 @@ def generateNestedQuery(getQuery, priority_list, criterion_dict,
**{my_criterion_id: impossible_value_list} **{my_criterion_id: impossible_value_list}
) )
query = NegatedQuery(query) query = NegatedQuery(query)
query = ComplexQuery(operator='OR', query = ComplexQuery(logical_operator='OR',
*(query, getQuery(**{my_criterion_id: None}))) *(query, getQuery(**{my_criterion_id: None})))
value_query_list.append(query) value_query_list.append(query)
append(ComplexQuery(operator='AND', *value_query_list)) append(ComplexQuery(logical_operator='AND', *value_query_list))
if len(query_list): if len(query_list):
return ComplexQuery(operator='OR', *query_list) return ComplexQuery(logical_operator='OR', *query_list)
return None return None
def getWorklistListQuery(getQuery, grouped_worklist_dict): def getWorklistListQuery(getQuery, grouped_worklist_dict):
......
...@@ -162,7 +162,7 @@ def wholePeriod(search_key, group, column, value_list, exclude=False): ...@@ -162,7 +162,7 @@ def wholePeriod(search_key, group, column, value_list, exclude=False):
first_date, second_date = getPeriodBoundaries(value) first_date, second_date = getPeriodBoundaries(value)
append(ComplexQuery([SimpleQuery(search_key=search_key, comparison_operator=first_operator, group=group, **{column: first_date}), append(ComplexQuery([SimpleQuery(search_key=search_key, comparison_operator=first_operator, group=group, **{column: first_date}),
SimpleQuery(search_key=search_key, comparison_operator=second_operator, group=group, **{column: second_date})], SimpleQuery(search_key=search_key, comparison_operator=second_operator, group=group, **{column: second_date})],
operator=logical_operator)) logical_operator=logical_operator))
return query_list return query_list
def matchWholePeriod(search_key, group, column, value_list, *ignored): def matchWholePeriod(search_key, group, column, value_list, *ignored):
......
...@@ -231,7 +231,7 @@ class RelatedKey(SearchKey): ...@@ -231,7 +231,7 @@ class RelatedKey(SearchKey):
# Example: # Example:
# ComplexQuery(Query(title="foo"), # ComplexQuery(Query(title="foo"),
# Query(subordination_title="bar") # Query(subordination_title="bar")
# , operator='OR') # , logical_operator='OR')
# Former catalog rendering (truncated where-expression): # Former catalog rendering (truncated where-expression):
# AND ((catalog.title LIKE '%foo%') OR # AND ((catalog.title LIKE '%foo%') OR
# (related_catalog_1.title LIKE '%bar%')) # (related_catalog_1.title LIKE '%bar%'))
......
...@@ -362,7 +362,7 @@ class SearchKey(object): ...@@ -362,7 +362,7 @@ class SearchKey(object):
if len(query_list) == 1: if len(query_list) == 1:
query = query_list[0] query = query_list[0]
else: else:
query = ComplexQuery(query_list, operator=logical_operator) query = ComplexQuery(query_list, logical_operator=logical_operator)
return query return query
def parseSearchText(self, value, is_column): def parseSearchText(self, value, is_column):
......
...@@ -121,16 +121,16 @@ if __name__ == '__main__': ...@@ -121,16 +121,16 @@ if __name__ == '__main__':
return not (self == other) return not (self == other)
class ComplexQuery: class ComplexQuery:
def __init__(self, query_list, operator): def __init__(self, query_list, logical_operator):
self.operator = operator self.logical_operator = logical_operator
self.query_list = query_list self.query_list = query_list
def __repr__(self): def __repr__(self):
return 'ComplexQuery(%r, operator=%r)' % (self.query_list, self.operator) return 'ComplexQuery(%r, logical_operator=%r)' % (self.query_list, self.logical_operator)
def __eq__(self, other): def __eq__(self, other):
if isinstance(other, ComplexQuery): if isinstance(other, ComplexQuery):
if self.operator != other.operator: if self.logical_operator != other.logical_operator:
return False return False
other_query_list = other.query_list[:] other_query_list = other.query_list[:]
for my_query in self.query_list: for my_query in self.query_list:
...@@ -178,17 +178,17 @@ if __name__ == '__main__': ...@@ -178,17 +178,17 @@ if __name__ == '__main__':
('+1', None), ('+1', None),
('-1', None), ('-1', None),
('foo OR "-" OR bar OR -baz', ComplexQuery([Query(None, 'foo'), Query(None, '-'), Query(None, 'bar'), Query(None, '-baz')], operator='or')), ('foo OR "-" OR bar OR -baz', ComplexQuery([Query(None, 'foo'), Query(None, '-'), Query(None, 'bar'), Query(None, '-baz')], logical_operator='or')),
('foo "-" bar -baz', ComplexQuery([Query(None, 'foo'), Query(None, '-'), Query(None, 'bar'), Query(None, '-baz')], operator='and')), ('foo "-" bar -baz', ComplexQuery([Query(None, 'foo'), Query(None, '-'), Query(None, 'bar'), Query(None, '-baz')], logical_operator='and')),
('title:foo', Query('title', 'foo')), ('title:foo', Query('title', 'foo')),
('title: foo', Query('title', 'foo')), ('title: foo', Query('title', 'foo')),
('title:foo bar', ComplexQuery([Query('title', 'foo'), Query(None, 'bar')], operator='and')), ('title:foo bar', ComplexQuery([Query('title', 'foo'), Query(None, 'bar')], logical_operator='and')),
('title:"foo bar"', Query('title', 'foo bar')), ('title:"foo bar"', Query('title', 'foo bar')),
('"title:foo bar"', Query(None, 'title:foo bar')), ('"title:foo bar"', Query(None, 'title:foo bar')),
('"foo bar"', Query(None, 'foo bar')), ('"foo bar"', Query(None, 'foo bar')),
('"foo bar"', Query(None, 'foo bar')), ('"foo bar"', Query(None, 'foo bar')),
('foo AND bar', ComplexQuery([Query(None, 'foo'), Query(None, 'bar')], operator='and')), ('foo AND bar', ComplexQuery([Query(None, 'foo'), Query(None, 'bar')], logical_operator='and')),
('foo OR bar', ComplexQuery([Query(None, 'foo'), Query(None, 'bar')], operator='or')), ('foo OR bar', ComplexQuery([Query(None, 'foo'), Query(None, 'bar')], logical_operator='or')),
('"foo AND bar"', Query(None, 'foo AND bar')), ('"foo AND bar"', Query(None, 'foo AND bar')),
('"foo and bar"', Query(None, 'foo and bar')), ('"foo and bar"', Query(None, 'foo and bar')),
('"foo OR bar"', Query(None, 'foo OR bar')), ('"foo OR bar"', Query(None, 'foo OR bar')),
...@@ -199,18 +199,18 @@ if __name__ == '__main__': ...@@ -199,18 +199,18 @@ if __name__ == '__main__':
('">1"', Query(None, '>1')), ('">1"', Query(None, '>1')),
('>a', Query(None, 'a', '>')), ('>a', Query(None, 'a', '>')),
('">a"', Query(None, '>a')), ('">a"', Query(None, '>a')),
('>1 0', ComplexQuery([Query(None, '1', '>'), Query(None, '0')], operator='and')), ('>1 0', ComplexQuery([Query(None, '1', '>'), Query(None, '0')], logical_operator='and')),
('>=1', Query(None, '1', '>=')), ('>=1', Query(None, '1', '>=')),
('>"=1"', Query(None, '=1', '>')), ('>"=1"', Query(None, '=1', '>')),
('-"1"', ComplexQuery([Query(None, '-'), Query(None, '1')], operator='and')), ('-"1"', ComplexQuery([Query(None, '-'), Query(None, '1')], logical_operator='and')),
('"!-1"', Query(None, '!-1')), ('"!-1"', Query(None, '!-1')),
# (r"a:'tu:\'tu\''", ['a', "tu:'tu'"]), # (r"a:'tu:\'tu\''", ['a', "tu:'tu'"]),
(r'''b:"tu:\'tu\'"''', Query('b', "tu:\\'tu\\'")), (r'''b:"tu:\'tu\'"''', Query('b', "tu:\\'tu\\'")),
(r'''c:"tu:'tu'"''', Query('c', "tu:'tu'")), (r'''c:"tu:'tu'"''', Query('c', "tu:'tu'")),
(r'd:"tu:\"tu\""', Query('d', 'tu:"tu"')), (r'd:"tu:\"tu\""', Query('d', 'tu:"tu"')),
('toto: tutu tutu', ComplexQuery([Query('toto', 'tutu'), Query(None, 'tutu')], operator='and')), ('toto: tutu tutu', ComplexQuery([Query('toto', 'tutu'), Query(None, 'tutu')], logical_operator='and')),
('(tutu) (toto:tata)', ComplexQuery([Query(None, 'tutu'), Query('toto', 'tata')], operator='and')), ('(tutu) (toto:tata)', ComplexQuery([Query(None, 'tutu'), Query('toto', 'tata')], logical_operator='and')),
('(tutu) (toto:"tata")', ComplexQuery([Query(None, 'tutu'), Query('toto', 'tata')], operator='and')), ('(tutu) (toto:"tata")', ComplexQuery([Query(None, 'tutu'), Query('toto', 'tata')], logical_operator='and')),
# ('toto:', ['toto', '']), # ('toto:', ['toto', '']),
('toto:""', Query('toto', '')), ('toto:""', Query('toto', '')),
# ("''", ''), # ("''", ''),
...@@ -219,49 +219,49 @@ if __name__ == '__main__': ...@@ -219,49 +219,49 @@ if __name__ == '__main__':
(r'"\n"', Query(None, '\\n')), (r'"\n"', Query(None, '\\n')),
#こんにちは #こんにちは
(u'ん', None), (u'ん', None),
(u'(toto:ん) OR (titi:ん)', ComplexQuery([Query('toto', u'ん'), Query('titi', u'ん')], operator='or')), (u'(toto:ん) OR (titi:ん)', ComplexQuery([Query('toto', u'ん'), Query('titi', u'ん')], logical_operator='or')),
('ん', None), ('ん', None),
('(toto:ん) OR (titi:ん)', ComplexQuery([Query('toto', 'ん'), Query('titi', 'ん')], operator='or')), ('(toto:ん) OR (titi:ん)', ComplexQuery([Query('toto', 'ん'), Query('titi', 'ん')], logical_operator='or')),
('(foo)', Query(None, 'foo')), ('(foo)', Query(None, 'foo')),
('toto:(foo)', Query('toto', 'foo')), ('toto:(foo)', Query('toto', 'foo')),
('(foo OR bar)', ComplexQuery([Query(None, 'foo'), Query(None, 'bar')], operator='or')), ('(foo OR bar)', ComplexQuery([Query(None, 'foo'), Query(None, 'bar')], logical_operator='or')),
('(a AND b) OR (c AND (d OR e))', ('(a AND b) OR (c AND (d OR e))',
ComplexQuery([ComplexQuery([Query(None, 'a'), Query(None, 'b')], operator='and'), ComplexQuery([Query(None, 'c'), ComplexQuery([Query(None, 'd'), Query(None, 'e')], operator='or')], operator='and')], operator='or')), ComplexQuery([ComplexQuery([Query(None, 'a'), Query(None, 'b')], logical_operator='and'), ComplexQuery([Query(None, 'c'), ComplexQuery([Query(None, 'd'), Query(None, 'e')], logical_operator='or')], logical_operator='and')], logical_operator='or')),
('(foo:"") (bar:baz)', ComplexQuery([Query('foo', ''), Query('bar', 'baz')], operator='and')), ('(foo:"") (bar:baz)', ComplexQuery([Query('foo', ''), Query('bar', 'baz')], logical_operator='and')),
('(foo:"") (OR:bar)', ComplexQuery([Query('foo', ''), Query(None, 'OR:bar')], operator='and')), ('(foo:"") (OR:bar)', ComplexQuery([Query('foo', ''), Query(None, 'OR:bar')], logical_operator='and')),
# ('foo: OR', ['foo', 'or']), # ('foo: OR', ['foo', 'or']),
# ('foo: OR ', ['foo', 'or']), # ('foo: OR ', ['foo', 'or']),
# ('(foo:)', ['foo', '']), # ('(foo:)', ['foo', '']),
('(foo: bar)', Query('foo', 'bar')), ('(foo: bar)', Query('foo', 'bar')),
('(a:b) AND (c:d)', ComplexQuery([Query('a', 'b'), Query('c', 'd')], operator='and')), ('(a:b) AND (c:d)', ComplexQuery([Query('a', 'b'), Query('c', 'd')], logical_operator='and')),
('a:(b c)', ComplexQuery([Query('a', 'b'), Query('a', 'c')], operator='or')), ('a:(b c)', ComplexQuery([Query('a', 'b'), Query('a', 'c')], logical_operator='or')),
('a:(b OR c)', ComplexQuery([Query('a', 'b'), Query('a', 'c')], operator='or')), ('a:(b OR c)', ComplexQuery([Query('a', 'b'), Query('a', 'c')], logical_operator='or')),
('a:(b c d)', ComplexQuery([Query('a', 'b'), Query('a', 'c'), Query('a', 'd')], operator='or')), ('a:(b c d)', ComplexQuery([Query('a', 'b'), Query('a', 'c'), Query('a', 'd')], logical_operator='or')),
('a:(b (c d))', ComplexQuery([Query('a', 'b'), Query('a', 'c'), Query('a', 'd')], operator='or')), ('a:(b (c d))', ComplexQuery([Query('a', 'b'), Query('a', 'c'), Query('a', 'd')], logical_operator='or')),
('a:(b OR (c d))', ComplexQuery([Query('a', 'b'), Query('a', 'c'), Query('a', 'd')], operator='or')), ('a:(b OR (c d))', ComplexQuery([Query('a', 'b'), Query('a', 'c'), Query('a', 'd')], logical_operator='or')),
('"JeanANDPaul"', Query(None, 'JeanANDPaul')), ('"JeanANDPaul"', Query(None, 'JeanANDPaul')),
('"Jean" AND "Paul"', ComplexQuery([Query(None, 'Jean'), Query(None, 'Paul')], operator='and')), ('"Jean" AND "Paul"', ComplexQuery([Query(None, 'Jean'), Query(None, 'Paul')], logical_operator='and')),
('"jean paul" OR "thierry"', ComplexQuery([Query(None, 'jean paul'), Query(None, 'thierry')], operator='or')), ('"jean paul" OR "thierry"', ComplexQuery([Query(None, 'jean paul'), Query(None, 'thierry')], logical_operator='or')),
('title:Paul Jean Lili', ComplexQuery([Query('title', 'Paul'), Query(None, 'Jean'), Query(None, 'Lili')], operator='and')), ('title:Paul Jean Lili', ComplexQuery([Query('title', 'Paul'), Query(None, 'Jean'), Query(None, 'Lili')], logical_operator='and')),
('toto AND titi OR tutu AND tata OR toto', ('toto AND titi OR tutu AND tata OR toto',
ComplexQuery([ComplexQuery([Query(None, 'toto'), Query(None, 'titi')], operator='and'), ComplexQuery([Query(None, 'tutu'), Query(None, 'tata')], operator='and'), Query(None, 'toto')], operator='or')), ComplexQuery([ComplexQuery([Query(None, 'toto'), Query(None, 'titi')], logical_operator='and'), ComplexQuery([Query(None, 'tutu'), Query(None, 'tata')], logical_operator='and'), Query(None, 'toto')], logical_operator='or')),
('toto AND (titi OR tutu) AND tata OR toto', ('toto AND (titi OR tutu) AND tata OR toto',
ComplexQuery([ComplexQuery([Query(None, 'toto'), ComplexQuery([Query(None, 'titi'), Query(None, 'tutu')], operator='or'), Query(None, 'tata')], operator='and'), Query(None, 'toto')], operator='or')), ComplexQuery([ComplexQuery([Query(None, 'toto'), ComplexQuery([Query(None, 'titi'), Query(None, 'tutu')], logical_operator='or'), Query(None, 'tata')], logical_operator='and'), Query(None, 'toto')], logical_operator='or')),
('"OR ARGENT"', Query(None, 'OR ARGENT')), ('"OR ARGENT"', Query(None, 'OR ARGENT')),
('1 AND 2 OR 3', ComplexQuery([ComplexQuery([Query(None, '1'), Query(None, '2')], operator='and'), Query(None, '3')], operator='or')), ('1 AND 2 OR 3', ComplexQuery([ComplexQuery([Query(None, '1'), Query(None, '2')], logical_operator='and'), Query(None, '3')], logical_operator='or')),
('1 OR 2 AND 3', ComplexQuery([Query(None, '1'), ComplexQuery([Query(None, '2'), Query(None, '3')], operator='and')], operator='or')), ('1 OR 2 AND 3', ComplexQuery([Query(None, '1'), ComplexQuery([Query(None, '2'), Query(None, '3')], logical_operator='and')], logical_operator='or')),
('1 AND 2 3', ComplexQuery([Query(None, '1'), Query(None, '2'), Query(None, '3')], operator='and')), ('1 AND 2 3', ComplexQuery([Query(None, '1'), Query(None, '2'), Query(None, '3')], logical_operator='and')),
('1 2 AND 3', ComplexQuery([Query(None, '1'), Query(None, '2'), Query(None, '3')], operator='and')), ('1 2 AND 3', ComplexQuery([Query(None, '1'), Query(None, '2'), Query(None, '3')], logical_operator='and')),
('10 11 AND 12 13', ComplexQuery([Query(None, '10'), Query(None, '11'), Query(None, '12'), Query(None, '13')], operator='and')), ('10 11 AND 12 13', ComplexQuery([Query(None, '10'), Query(None, '11'), Query(None, '12'), Query(None, '13')], logical_operator='and')),
('1 OR 2 3', ComplexQuery([Query(None, '1'), ComplexQuery([Query(None, '2'), Query(None, '3')], operator='and')], operator='or')), ('1 OR 2 3', ComplexQuery([Query(None, '1'), ComplexQuery([Query(None, '2'), Query(None, '3')], logical_operator='and')], logical_operator='or')),
('1 2 OR 3', ComplexQuery([ComplexQuery([Query(None, '1'), Query(None, '2')], operator='and'), Query(None, '3')], operator='or')), ('1 2 OR 3', ComplexQuery([ComplexQuery([Query(None, '1'), Query(None, '2')], logical_operator='and'), Query(None, '3')], logical_operator='or')),
('10 11 OR 12 13', ComplexQuery([ComplexQuery([Query(None, '10'), Query(None, '11')], operator='and'), ComplexQuery([Query(None, '12'), Query(None, '13')], operator='and')], operator='or')), ('10 11 OR 12 13', ComplexQuery([ComplexQuery([Query(None, '10'), Query(None, '11')], logical_operator='and'), ComplexQuery([Query(None, '12'), Query(None, '13')], logical_operator='and')], logical_operator='or')),
('((1 AND 2 OR 3) OR (4 OR 5 6) OR (7 8 OR 9) OR (10 11 OR 12 13))', ('((1 AND 2 OR 3) OR (4 OR 5 6) OR (7 8 OR 9) OR (10 11 OR 12 13))',
ComplexQuery([ComplexQuery([Query(None, '1', '='), Query(None, '2', '=')], operator='and'), Query(None, '3', '='), Query(None, '4', '='), ComplexQuery([Query(None, '5', '='), Query(None, '6', '=')], operator='and'), ComplexQuery([Query(None, '7', '='), Query(None, '8', '=')], operator='and'), Query(None, '9', '='), ComplexQuery([Query(None, '10', '='), Query(None, '11', '=')], operator='and'), ComplexQuery([Query(None, '12', '='), Query(None, '13', '=')], operator='and')], operator='or')), ComplexQuery([ComplexQuery([Query(None, '1', '='), Query(None, '2', '=')], logical_operator='and'), Query(None, '3', '='), Query(None, '4', '='), ComplexQuery([Query(None, '5', '='), Query(None, '6', '=')], logical_operator='and'), ComplexQuery([Query(None, '7', '='), Query(None, '8', '=')], logical_operator='and'), Query(None, '9', '='), ComplexQuery([Query(None, '10', '='), Query(None, '11', '=')], logical_operator='and'), ComplexQuery([Query(None, '12', '='), Query(None, '13', '=')], logical_operator='and')], logical_operator='or')),
('((titi:foo) AND (toto:bar)) OR ((titi:bar) AND (toto:foo))', ('((titi:foo) AND (toto:bar)) OR ((titi:bar) AND (toto:foo))',
ComplexQuery([ComplexQuery([Query('titi', 'foo'), Query('toto', 'bar')], operator='and'), ComplexQuery([Query('titi', 'bar'), Query('toto', 'foo')], operator='and')], operator='or')), ComplexQuery([ComplexQuery([Query('titi', 'foo'), Query('toto', 'bar')], logical_operator='and'), ComplexQuery([Query('titi', 'bar'), Query('toto', 'foo')], logical_operator='and')], logical_operator='or')),
('title:(Paul Jean OR Lili)', ComplexQuery([Query('title', 'Paul'), Query('title', 'Jean'), Query('title', 'Lili')], operator='or')), ('title:(Paul Jean OR Lili)', ComplexQuery([Query('title', 'Paul'), Query('title', 'Jean'), Query('title', 'Lili')], logical_operator='or')),
('title:Paul Jean OR Lili', ComplexQuery([ComplexQuery([Query('title', 'Paul'), Query(None, 'Jean')], operator='and'), Query(None, 'Lili')], operator='or')), ('title:Paul Jean OR Lili', ComplexQuery([ComplexQuery([Query('title', 'Paul'), Query(None, 'Jean')], logical_operator='and'), Query(None, 'Lili')], logical_operator='or')),
] ]
def walk(node, key=None): def walk(node, key=None):
...@@ -279,7 +279,7 @@ if __name__ == '__main__': ...@@ -279,7 +279,7 @@ if __name__ == '__main__':
query_list = [walk(x, key) for x in node.getNodeList()] query_list = [walk(x, key) for x in node.getNodeList()]
operator = node.getLogicalOperator() operator = node.getLogicalOperator()
if operator == 'not' or len(query_list) > 1: if operator == 'not' or len(query_list) > 1:
result = ComplexQuery(query_list, operator=operator) result = ComplexQuery(query_list, logical_operator=logical_operator)
elif len(query_list) == 1: elif len(query_list) == 1:
result = query_list[0] result = query_list[0]
else: else:
......
...@@ -825,7 +825,7 @@ class TestSQLCatalog(ERP5TypeTestCase): ...@@ -825,7 +825,7 @@ class TestSQLCatalog(ERP5TypeTestCase):
#return catalog(title={'query': 'a', 'operator': 'not'}) #return catalog(title={'query': 'a', 'operator': 'not'})
#return catalog(title={'query': ['a', 'b'], 'operator': 'not'}) #return catalog(title={'query': ['a', 'b'], 'operator': 'not'})
#return context.portal_catalog(source_title="toto", source_description="tutu", src__=1) #return context.portal_catalog(source_title="toto", source_description="tutu", src__=1)
#print catalog(query=ComplexQuery(Query(title='1'), ComplexQuery(Query(portal_type='Foo') ,Query(portal_type='Bar'), operator='or'), operator='and')) #print catalog(query=ComplexQuery(Query(title='1'), ComplexQuery(Query(portal_type='Foo') ,Query(portal_type='Bar'), logical_operator='or'), logical_operator='and'))
#print catalog(title={'query': ('path', 2), 'operator': 'and'}, exception=TypeError) #print catalog(title={'query': ('path', 2), 'operator': 'and'}, exception=TypeError)
#print catalog(sort_on=[('source_title', )], check_search_text=False) #print catalog(sort_on=[('source_title', )], check_search_text=False)
#print catalog(query=ComplexQuery(Query(source_title='foo'), Query(source_title='bar')), sort_on=[('source_title', ), ('source_title_1', )], check_search_text=False) #print catalog(query=ComplexQuery(Query(source_title='foo'), Query(source_title='bar')), sort_on=[('source_title', ), ('source_title_1', )], check_search_text=False)
......
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