From e4afbc98cdac156a240326c78599c79d43e67c22 Mon Sep 17 00:00:00 2001 From: Doug Blank Date: Sat, 23 Apr 2016 12:50:37 -0400 Subject: [PATCH] Postgresql and Mysql LIMIT fixes --- gramps/plugins/database/dbapi_support/mysql.py | 5 +++-- gramps/plugins/database/dbapi_support/postgresql.py | 3 +++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/gramps/plugins/database/dbapi_support/mysql.py b/gramps/plugins/database/dbapi_support/mysql.py index c987ae681..555fa54c5 100644 --- a/gramps/plugins/database/dbapi_support/mysql.py +++ b/gramps/plugins/database/dbapi_support/mysql.py @@ -35,8 +35,9 @@ class MySQL(object): ## LIMIT -1 ## LIMIT offset, -1 query = query.replace("LIMIT -1", - "LIMIT 18446744073709551615") ## largest maxint - #query = query.replace("LIMIT -1", "") + "LIMIT 18446744073709551615") ## + ## FIXME: regex match: + #query = query.replace("LIMIT .*,-1", "LIMIT $1, ALL") return query def execute(self, query, args=[]): diff --git a/gramps/plugins/database/dbapi_support/postgresql.py b/gramps/plugins/database/dbapi_support/postgresql.py index 975c99334..1a5a05e4b 100644 --- a/gramps/plugins/database/dbapi_support/postgresql.py +++ b/gramps/plugins/database/dbapi_support/postgresql.py @@ -28,6 +28,8 @@ class Postgresql(object): sql = sql.replace("?", "%s") sql = sql.replace("REGEXP", "~") sql = sql.replace("desc", "desc_") + sql = sql.replace("LIMIT -1", "LIMIT all") + ## FIXME: limit offset, -1 if len(args) > 1: args = args[1] else: @@ -57,6 +59,7 @@ class Postgresql(object): sql = sql.replace("?", "%s") sql = sql.replace("BLOB", "bytea") sql = sql.replace("desc", "desc_") + sql = sql.replace("LIMIT -1", "LIMIT all") try: self.cursor.execute(sql) except Exception as exc: