Commit 559a14f9 authored by Vincent Pelletier's avatar Vincent Pelletier

DomainTool: Simplify ranged properties discovery

Avoid iterating over all columns known to catalog to then restrict to a
single table by using SQLCatalog API.
Only check for one range column suffix as code anyway relies on the triplet
of columns to be consistently present. Document this in the code and get
rid of now-unneeded range_column_set mechanism.
parent 1f68abb2
...@@ -112,14 +112,13 @@ class DomainTool(BaseTool): ...@@ -112,14 +112,13 @@ class DomainTool(BaseTool):
portal_catalog = portal.portal_catalog portal_catalog = portal.portal_catalog
portal_categories = portal.portal_categories portal_categories = portal.portal_categories
# Search the columns of the predicate table # Search the columns of the predicate table
range_column_set = set()
query_list = [] if query is None else [query] query_list = [] if query is None else [query]
for column in portal_catalog.getColumnIds(): for column in portal_catalog.getSQLCatalog().getTableColumnList('predicate'):
if column[:10] == 'predicate.' and \ # Arbitrary suffix choice, this code expects COLUMN, COLUMN_range_min
column[-10:] in ('_range_min', '_range_max'): # and COLUMN_range_max to be simultaneously present for ranged
property_name = column[10:-10] # properties. Only checking one suffix simplifies the code flow.
if property_name not in range_column_set: if column.endswith('_range_min'):
range_column_set.add(property_name) property_name = column[:-10]
# We have to check a range property # We have to check a range property
equality = 'predicate.' + property_name equality = 'predicate.' + property_name
range_min = equality + '_range_min' range_min = equality + '_range_min'
......
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