From 38c663ee9559d9d01291b59b252b10282d7de930 Mon Sep 17 00:00:00 2001 From: shortcutme Date: Wed, 4 Oct 2017 13:10:26 +0200 Subject: [PATCH] Use WHERE 1 for queries without argument --- src/Db/DbCursor.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Db/DbCursor.py b/src/Db/DbCursor.py index 0b03a9f0..cff075de 100644 --- a/src/Db/DbCursor.py +++ b/src/Db/DbCursor.py @@ -32,7 +32,9 @@ class DbCursor: query_wheres.append(key + " = ?") values.append(value) wheres = " AND ".join(query_wheres) - query = re.sub("(.*)[?]", "\\1%s" % wheres, query) # Replace the last ? + if wheres == "": + wheres = "1" + query = re.sub("(.*)[?]", "\\1 %s" % wheres, query) # Replace the last ? params = values else: # Convert param dict to INSERT INTO table (key, key2) VALUES (?, ?) format