From: Michael Tremer Date: Sat, 13 Jan 2018 12:41:27 +0000 (+0000) Subject: Fix limit/offset syntax for PostgreSQL X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=9189660e4332be6f62eb565505f00a782a78a93b;p=pbs.git Fix limit/offset syntax for PostgreSQL Fixes #11587 Signed-off-by: Michael Tremer --- diff --git a/src/buildservice/builds.py b/src/buildservice/builds.py index 6f9974c1..83d5f241 100644 --- a/src/buildservice/builds.py +++ b/src/buildservice/builds.py @@ -101,13 +101,8 @@ class Builds(base.Object): elif type == "scratch": query += " ORDER BY time_created DESC" - if limit: - if offset: - query += " LIMIT %s,%s" - args.extend([offset, limit]) - else: - query += " LIMIT %s" - args.append(limit) + query += " LIMIT %s OFFSET %s" + args.extend([offset, limit]) return [Build(self.backend, b.id, b) for b in self.db.query(query, *args)] @@ -262,13 +257,8 @@ class Builds(base.Object): query += " ORDER BY builds.time_created DESC" - if limit: - if offset: - query += " LIMIT %s,%s" - args += [offset, limit] - else: - query += " LIMIT %s" - args.append(limit) + query += " LIMIT %s OFFSET %s" + args += [offset, limit] builds = [] for b in self.db.query(query, *args): @@ -296,14 +286,8 @@ class Builds(base.Object): query += " ORDER BY time_created DESC" # Limits. - if limit: - if offset: - query += " LIMIT %s,%s" - args.append(offset) - else: - query += " LIMIT %s" - - args.append(limit) + query += " LIMIT %s OFFSET %s" + args.extend([limit, offset]) comments = [] for comment in self.db.query(query, *args):