Patch for an Issue #421

This commit is contained in:
Miroslav Stampar 2013-03-15 22:08:15 +01:00
parent 596cf95040
commit f0a419bdec

View File

@ -899,6 +899,7 @@ class Agent(object):
def forgeQueryOutputLength(self, expression): def forgeQueryOutputLength(self, expression):
lengthQuery = queries[Backend.getIdentifiedDbms()].length.query lengthQuery = queries[Backend.getIdentifiedDbms()].length.query
select = re.search("\ASELECT\s+", expression, re.I) 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) selectTopExpr = re.search("\ASELECT\s+TOP\s+[\d]+\s+(.+?)\s+FROM", expression, re.I)
selectFromExpr = re.search("\ASELECT\s+(.+?)\s+FROM", expression, re.I) selectFromExpr = re.search("\ASELECT\s+(.+?)\s+FROM", expression, re.I)
selectExpr = re.search("\ASELECT\s+(.+)$", expression, re.I) selectExpr = re.search("\ASELECT\s+(.+)$", expression, re.I)
@ -910,7 +911,9 @@ class Agent(object):
else: else:
query = expression query = expression
if select: if selectTopNotIntExpr:
lengthExpr = lengthQuery % ("(%s)" % expression)
elif select:
lengthExpr = expression.replace(query, lengthQuery % query, 1) lengthExpr = expression.replace(query, lengthQuery % query, 1)
else: else:
lengthExpr = lengthQuery % expression lengthExpr = lengthQuery % expression