Postgresql and Mysql LIMIT fixes

This commit is contained in:
Doug Blank 2016-04-23 12:50:37 -04:00
parent cfd686ff59
commit e4afbc98cd
2 changed files with 6 additions and 2 deletions

View File

@ -35,8 +35,9 @@ class MySQL(object):
## LIMIT -1 ## LIMIT -1
## LIMIT offset, -1 ## LIMIT offset, -1
query = query.replace("LIMIT -1", query = query.replace("LIMIT -1",
"LIMIT 18446744073709551615") ## largest maxint "LIMIT 18446744073709551615") ##
#query = query.replace("LIMIT -1", "") ## FIXME: regex match:
#query = query.replace("LIMIT .*,-1", "LIMIT $1, ALL")
return query return query
def execute(self, query, args=[]): def execute(self, query, args=[]):

View File

@ -28,6 +28,8 @@ class Postgresql(object):
sql = sql.replace("?", "%s") sql = sql.replace("?", "%s")
sql = sql.replace("REGEXP", "~") sql = sql.replace("REGEXP", "~")
sql = sql.replace("desc", "desc_") sql = sql.replace("desc", "desc_")
sql = sql.replace("LIMIT -1", "LIMIT all")
## FIXME: limit offset, -1
if len(args) > 1: if len(args) > 1:
args = args[1] args = args[1]
else: else:
@ -57,6 +59,7 @@ class Postgresql(object):
sql = sql.replace("?", "%s") sql = sql.replace("?", "%s")
sql = sql.replace("BLOB", "bytea") sql = sql.replace("BLOB", "bytea")
sql = sql.replace("desc", "desc_") sql = sql.replace("desc", "desc_")
sql = sql.replace("LIMIT -1", "LIMIT all")
try: try:
self.cursor.execute(sql) self.cursor.execute(sql)
except Exception as exc: except Exception as exc: