mirror of
https://github.com/moparisthebest/SickRage
synced 2024-12-12 02:52:20 -05:00
Small SQL syntax fix
This commit is contained in:
parent
27ce22839c
commit
d26576122e
@ -36,6 +36,7 @@ from sickbeard import clients
|
||||
from name_parser.parser import NameParser, InvalidNameException, InvalidShowException
|
||||
from sickbeard import encodingKludge as ek
|
||||
|
||||
|
||||
class CacheDBConnection(db.DBConnection):
|
||||
def __init__(self, providerName):
|
||||
db.DBConnection.__init__(self, "cache.db")
|
||||
@ -47,7 +48,7 @@ class CacheDBConnection(db.DBConnection):
|
||||
"CREATE TABLE [" + providerName + "] (name TEXT, season NUMERIC, episodes TEXT, indexerid NUMERIC, url TEXT, time NUMERIC, quality TEXT, release_group TEXT)")
|
||||
else:
|
||||
sqlResults = self.select(
|
||||
"SELECT url, COUNT(url) as count FROM [" + providerName + "] GROUP BY url HAVING count > 1")
|
||||
"SELECT url, COUNT(url) AS count FROM [" + providerName + "] GROUP BY url HAVING count > 1")
|
||||
|
||||
for cur_dupe in sqlResults:
|
||||
self.action("DELETE FROM [" + providerName + "] WHERE url = ?", [cur_dupe["url"]])
|
||||
@ -75,6 +76,7 @@ class CacheDBConnection(db.DBConnection):
|
||||
if str(e) != "table lastUpdate already exists":
|
||||
raise
|
||||
|
||||
|
||||
class TVCache():
|
||||
def __init__(self, provider):
|
||||
|
||||
@ -233,7 +235,7 @@ class TVCache():
|
||||
if not parse_result:
|
||||
|
||||
# create showObj from indexer_id if available
|
||||
showObj=None
|
||||
showObj = None
|
||||
if indexer_id:
|
||||
showObj = helpers.findCertainShow(sickbeard.showList, indexer_id)
|
||||
|
||||
@ -305,8 +307,8 @@ class TVCache():
|
||||
else:
|
||||
for epObj in episode:
|
||||
cl.append([
|
||||
"SELECT * FROM [" + self.providerID + "] WHERE indexerid = ? AND season = ? AND episodes LIKE ? "
|
||||
"AND quality IN (" + ",".join([str(x) for x in epObj.wantedQuality]) + ")",
|
||||
"SELECT * FROM [" + self.providerID + "] WHERE indexerid = ? AND season = ? AND episodes LIKE ? AND quality IN (" + ",".join(
|
||||
[str(x) for x in epObj.wantedQuality]) + ")",
|
||||
[epObj.show.indexerid, epObj.season, "%|" + str(epObj.episode) + "|%"]])
|
||||
|
||||
sqlResults = myDB.mass_action(cl, fetchall=True)
|
||||
|
@ -28,20 +28,8 @@ class EncodingTests(unittest.TestCase):
|
||||
if not sickbeard.SYS_ENCODING or sickbeard.SYS_ENCODING in ('ANSI_X3.4-1968', 'US-ASCII', 'ASCII'):
|
||||
sickbeard.SYS_ENCODING = 'UTF-8'
|
||||
|
||||
if not hasattr(sys, "setdefaultencoding"):
|
||||
reload(sys)
|
||||
|
||||
try:
|
||||
# pylint: disable=E1101
|
||||
# On non-unicode builds this will raise an AttributeError, if encoding type is not valid it throws a LookupError
|
||||
sys.setdefaultencoding(sickbeard.SYS_ENCODING)
|
||||
except:
|
||||
sys.exit("Sorry, you MUST add the SickRage folder to the PYTHONPATH environment variable\n" +
|
||||
"or find another way to force Python to use " + sickbeard.SYS_ENCODING + " for string encoding.")
|
||||
|
||||
for s in strings:
|
||||
try:
|
||||
show_name = s.decode(sickbeard.SYS_ENCODING, 'xmlcharrefreplace')
|
||||
show_dir = ek.ek(os.path.join, rootDir, sanitizeFileName(s))
|
||||
self.assertTrue(isinstance(show_dir, unicode))
|
||||
except Exception, e:
|
||||
|
Loading…
Reference in New Issue
Block a user