another fix related to the bug reported by Alone Shell

This commit is contained in:
Miroslav Stampar 2011-03-24 17:08:14 +00:00
parent 82ab4c8dc2
commit f3858a5fcf
2 changed files with 5 additions and 5 deletions

View File

@ -674,15 +674,15 @@ class Agent:
if forgeNotIn:
limitedQuery = limitedQuery.replace("SELECT ", (limitStr % 1), 1)
if uniqueField and " ORDER BY " not in fromFrom:
if " ORDER BY " not in fromFrom:
# Reference: http://vorg.ca/626-the-MS-SQL-equivalent-to-MySQLs-limit-command
if " WHERE " in limitedQuery:
limitedQuery = "%s AND %s " % (limitedQuery, uniqueField)
limitedQuery = "%s AND %s " % (limitedQuery, uniqueField or field)
else:
limitedQuery = "%s WHERE ISNULL(%s,' ') " % (limitedQuery, uniqueField)
limitedQuery = "%s WHERE ISNULL(%s,' ') " % (limitedQuery, uniqueField or field)
limitedQuery += "NOT IN (%s" % (limitStr % num)
limitedQuery += "ISNULL(%s,' ') %s ORDER BY %s) ORDER BY %s" % (uniqueField, fromFrom, uniqueField, uniqueField)
limitedQuery += "ISNULL(%s,' ') %s ORDER BY %s) ORDER BY %s" % (uniqueField or field, fromFrom, uniqueField or field, uniqueField or field)
else:
if " WHERE " in limitedQuery:
limitedQuery = "%s AND %s " % (limitedQuery, field)

View File

@ -1078,7 +1078,7 @@ class Enumeration:
elif Backend.getIdentifiedDbms() == DBMS.MSSQL:
query = rootQuery.blind.query2 % (conf.db, conf.db, conf.db,
conf.db, column, conf.db,
conf.db, conf.db, conf.tbl)
conf.db, conf.db, conf.tbl if '.' not in conf.tbl else conf.tbl.split('.')[1])
elif Backend.getIdentifiedDbms() == DBMS.FIREBIRD:
query = rootQuery.blind.query2 % (conf.tbl, column)