Rev3864, Fix newsfeed sql query with many parameters
This commit is contained in:
parent
8dd3a8495b
commit
9b274415e0
4 changed files with 17 additions and 13 deletions
|
@ -13,7 +13,7 @@ class Config(object):
|
|||
|
||||
def __init__(self, argv):
|
||||
self.version = "0.6.5"
|
||||
self.rev = 3863
|
||||
self.rev = 3864
|
||||
self.argv = argv
|
||||
self.action = None
|
||||
self.pending_changes = {}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
import time
|
||||
import re
|
||||
from util import helper
|
||||
|
||||
|
||||
# Special sqlite cursor
|
||||
|
||||
|
@ -12,12 +14,6 @@ class DbCursor:
|
|||
self.cursor = conn.cursor()
|
||||
self.logging = False
|
||||
|
||||
def quoteValue(self, value):
|
||||
if type(value) is int:
|
||||
return str(value)
|
||||
else:
|
||||
return "'%s'" % value.replace("'", "''")
|
||||
|
||||
def execute(self, query, params=None):
|
||||
self.db.last_query_time = time.time()
|
||||
if isinstance(params, dict) and "?" in query: # Make easier select and insert by allowing dict params
|
||||
|
@ -35,7 +31,7 @@ class DbCursor:
|
|||
operator = "IN"
|
||||
if len(value) > 100:
|
||||
# Embed values in query to avoid "too many SQL variables" error
|
||||
query_values = ",".join(map(self.quoteValue, value))
|
||||
query_values = ",".join(map(helper.sqlquote, value))
|
||||
else:
|
||||
query_values = ",".join(["?"] * len(value))
|
||||
values += value
|
||||
|
|
|
@ -72,6 +72,13 @@ def getFreeSpace():
|
|||
return free_space
|
||||
|
||||
|
||||
def sqlquote(value):
|
||||
if type(value) is int:
|
||||
return str(value)
|
||||
else:
|
||||
return "'%s'" % value.replace("'", "''")
|
||||
|
||||
|
||||
def shellquote(*args):
|
||||
if len(args) == 1:
|
||||
return '"%s"' % args[0].replace('"', "")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue