zopefoundation/Products.ZCatalog

"ValueError: too many values to unpack" when querying indexes with more that one _

Closed this issue · 4 comments

While updating a Plone 5.0.4 site to 5.2.3 I ran into this Error

  Module plone.api.content, line 664, in find
  Module Products.CMFPlone.CatalogTool, line 463, in searchResults
  Module Products.ZCatalog.ZCatalog, line 625, in searchResults
  Module Products.ZCatalog.Catalog, line 1091, in searchResults
  Module Products.ZCatalog.Catalog, line 634, in search
  Module Products.ZCatalog.Catalog, line 562, in _search_index
  Module Products.ZCatalog.query, line 91, in __init__
ValueError: too many values to unpack
....

(Pdb++) request
{'prioritization_lv1_effective': datetime.datetime(2021, 1, 22, 14, 6, 8, 965079), 'allowedRolesAndUsers': ['Anonymous', 'Authenticated', 'Manager', 'user:admin'], 'sort_on': ['effective'], 'sort_order': 'reverse', 'prioritization_lv1': True}
(Pdb++) field
'prioritization_lv1_effective'
(Pdb++) field.split('_')
['prioritization', 'lv1', 'effective']

Looks like the changes in 64b1f3b cause this error.

Probably an field.lsplit('_', 1) would fix it?

@jensens I think field.rsplit('_', 1) is the correct fix. Only the last part is allowed as index operator. But in @agitator 's case its also wrong, because he doesn't pass any operators to the index. The only way to get around this is to submit the query value as dict to skip the "underscore" logic ...

just found this open PR: #79 ... if this gets updated with rsplit update: this PR solves this issue without rsplitbecause of field.split(iid + "_") ... more elegant

/cc @thet

Fixed in #116.