Commit bfac1fbf authored by Nicolas Wavrant's avatar Nicolas Wavrant

SQLCatalog: allow "desc" as a sort keyword

Some listboxes in ERP5 use "| desc" to sort elements, even if it
didn't work (ie: Base_viewEventList/listbox).
Also, as "asc" is working (because descending sort is defined by
whitelist), adding "desc" makes things more consistent
parent 888e2f04
......@@ -2348,7 +2348,7 @@ class Catalog(Folder,
if sort_order is not None and len(item) == 1:
item.append(sort_order)
if len(item) > 1:
if item[1] in ('descending', 'reverse', 'DESC'):
if item[1] in ('descending', 'reverse', 'desc', 'DESC'):
item[1] = 'DESC'
else:
item[1] = 'ASC'
......
  • What about converting the existing DESC to desc, and adding a .lower() ? One less item, and no incentive to later (at least) double the list.

  • Indeed, it's possible too. I didn't know if we want to allow all case-randomly written keywords to be allowed. For exemple, "DeSceNDiNg" would work. But, even if it currently doesn't work, "AsCenDINg" currently works... Do you want me to fixup ?

  • I would tend to follow SQL on this: they are case-insensitive, so we could as well be. If you can spare the time do such follow-up commit, please do.

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