Skip to content

Commit dded57f

Browse files
committed
Minor bug fix to correctly unpack user's custom queries on Microsoft SQL Server
1 parent ad03684 commit dded57f

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

lib/core/agent.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,10 @@ def limitQuery(self, num, query, field):
476476

477477
if not limitedQuery.startswith("SELECT TOP ") and not limitedQuery.startswith("TOP "):
478478
limitedQuery = limitedQuery.replace("SELECT ", (limitStr % 1), 1)
479-
limitedQuery = "%s WHERE %s " % (limitedQuery, field)
479+
if " WHERE " in limitedQuery:
480+
limitedQuery = "%s AND %s " % (limitedQuery, field)
481+
else:
482+
limitedQuery = "%s WHERE %s " % (limitedQuery, field)
480483
limitedQuery += "NOT IN (%s" % (limitStr % num)
481484
limitedQuery += "%s %s)" % (field, fromFrom)
482485
else:

0 commit comments

Comments
 (0)