[#7278] ticket:638 Fix bug in translate_query
diff --git a/Allura/allura/model/artifact.py b/Allura/allura/model/artifact.py
index 81d9e7a..2639021 100644
--- a/Allura/allura/model/artifact.py
+++ b/Allura/allura/model/artifact.py
@@ -137,6 +137,11 @@
``fields``.
"""
+ # Replace longest fields first to avoid problems when field names have
+ # the same suffixes, but different field types. E.g.:
+ # query 'shortname:test' with fields.keys() == ['name_t', 'shortname_s']
+ # will be translated to 'shortname_t:test', which makes no sense
+ fields = sorted(fields.keys(), key=len, reverse=True)
for f in fields:
if '_' in f:
base, typ = f.rsplit('_', 1)