From c71d435d9fa8296c5c766c7305904002ca0514cd Mon Sep 17 00:00:00 2001 From: Miroslav Stampar Date: Tue, 1 May 2012 19:52:02 +0000 Subject: [PATCH] making "id"-like columns prioritized for ORDER BY in MySQL --- plugins/generic/enumeration.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/generic/enumeration.py b/plugins/generic/enumeration.py index f2bec00d3..e9bfe07cd 100644 --- a/plugins/generic/enumeration.py +++ b/plugins/generic/enumeration.py @@ -1608,7 +1608,8 @@ class Enumeration: else: query = rootQuery.inband.query % (colString, conf.db, tbl) elif Backend.getIdentifiedDbms() in (DBMS.MYSQL, DBMS.PGSQL): - query = rootQuery.inband.query % (colString, conf.db, tbl, sorted(colList, key=len)[0]) + _ = sorted(sorted(colList, key=len), lambda x, y: -1 if x and "id" in x.lower() else 1 if y and "id" in y.lower() else 0) + query = rootQuery.inband.query % (colString, conf.db, tbl, _[0]) else: query = rootQuery.inband.query % (colString, conf.db, tbl)