Commit 7eb59127 authored by Alexandre Boeglin's avatar Alexandre Boeglin

Modified usage of dictionary in buildSQLQuery to conform to ZCatalog/help/ZCatalog_Parameters.stx .

Also added an extra range parameter : 'ngt' which stands for 'not greater than'.
'ngt' selects everything that is inferior or equal to the value,
whereas 'max' selects what is strictly inferior to it.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@2717 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent fb41344a
...@@ -1387,14 +1387,29 @@ class Catalog(Folder, Persistent, Acquisition.Implicit, ExtensionClass.Base): ...@@ -1387,14 +1387,29 @@ class Catalog(Folder, Persistent, Acquisition.Implicit, ExtensionClass.Base):
where_expression += ['(%s)' % join(query_item, ' OR ')] where_expression += ['(%s)' % join(query_item, ' OR ')]
elif type(value) is type({}): elif type(value) is type({}):
# We are in the case of a complex query # We are in the case of a complex query
query_item = []
query_value = value['query'] query_value = value['query']
if value.has_key('range'): if type(query_value) != type([]) and type(query_value) != type(()) :
# This is a range query_value = [query_value]
range_value = value['range'] operator_value = value.get('operator', 'or')
if range_value == 'min': range_value = value.get('range')
where_expression += ["%s >= '%s'" % (key, query_value)]
elif range_value == 'max': if range_value :
where_expression += ["%s < '%s'" % (key, query_value)] query_min = min(query_value)
query_max = max(query_value)
if range_value == 'min' :
query_item += ['%s >= %s' % (key, str(query_min)) ]
elif range_value == 'max' :
query_item += ['%s < %s' % (key, str(query_max)) ]
elif range_value == 'minmax' :
query_item += ['%s >= %s and %s < %s' % (key, str(query_min), key, str(query_max)) ]
elif range_value == 'ngt' :
query_item += ['%s <= %s' % (key, str(query_max)) ]
else :
for query_value_item in query_value :
query_item += ['%s = %s' % (key, str(query_value_item))]
if len(query_item) > 0:
where_expression += ['(%s)' % join(query_item, ' %s ' % operator_value)]
else: else:
where_expression += ["%s = %s" % (key, value)] where_expression += ["%s = %s" % (key, value)]
elif key in topic_search_keys: elif key in topic_search_keys:
......
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