From f0a419bdec068bd0780cc8f5d8b8f882fc22af86 Mon Sep 17 00:00:00 2001 From: Miroslav Stampar Date: Fri, 15 Mar 2013 22:08:15 +0100 Subject: [PATCH] Patch for an Issue #421 --- lib/core/agent.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/core/agent.py b/lib/core/agent.py index 8fadf1a1c..b912c6721 100644 --- a/lib/core/agent.py +++ b/lib/core/agent.py @@ -899,6 +899,7 @@ class Agent(object): def forgeQueryOutputLength(self, expression): lengthQuery = queries[Backend.getIdentifiedDbms()].length.query select = re.search("\ASELECT\s+", expression, re.I) + selectTopNotIntExpr = re.search("\ASELECT\s+TOP\s+[\d]+\s+(.+?)\s+FROM.+NOT IN", expression, re.I) selectTopExpr = re.search("\ASELECT\s+TOP\s+[\d]+\s+(.+?)\s+FROM", expression, re.I) selectFromExpr = re.search("\ASELECT\s+(.+?)\s+FROM", expression, re.I) selectExpr = re.search("\ASELECT\s+(.+)$", expression, re.I) @@ -910,7 +911,9 @@ class Agent(object): else: query = expression - if select: + if selectTopNotIntExpr: + lengthExpr = lengthQuery % ("(%s)" % expression) + elif select: lengthExpr = expression.replace(query, lengthQuery % query, 1) else: lengthExpr = lengthQuery % expression