Use WHERE 1 for queries without argument

This commit is contained in:
shortcutme 2017-10-04 13:10:26 +02:00
parent ca473d6c3b
commit 38c663ee95
No known key found for this signature in database
GPG key ID: 5B63BAE6CB9613AE

View file

@ -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