Revert "Start id numbering with 0, not 1"

This reverts commit 22ddd28f0b.
This commit is contained in:
croneter 2018-03-04 13:39:40 +01:00
parent 8272a67b5f
commit 275283616e
2 changed files with 22 additions and 23 deletions

View file

@ -207,7 +207,7 @@ class Movies(Items):
except TypeError:
# movieid
update_item = False
kodicursor.execute("SELECT COALESCE(MAX(idMovie),-1) FROM movie")
kodicursor.execute("select coalesce(max(idMovie),0) from movie")
movieid = kodicursor.fetchone()[0] + 1
else:
@ -547,7 +547,7 @@ class TVShows(Items):
pathid = plex_dbitem[2]
except TypeError:
update_item = False
kodicursor.execute("SELECT COALESCE(MAX(idShow),-1) from tvshow")
kodicursor.execute("select coalesce(max(idShow),0) from tvshow")
showid = kodicursor.fetchone()[0] + 1
else:
@ -834,8 +834,7 @@ class TVShows(Items):
except TypeError:
update_item = False
# episodeid
query = 'SELECT COALESCE(MAX(idEpisode),-1) FROM episode'
kodicursor.execute(query)
kodicursor.execute("select coalesce(max(idEpisode),0) from episode")
episodeid = kodicursor.fetchone()[0] + 1
else:
# Verification the item is still in Kodi
@ -1594,7 +1593,7 @@ class Music(Items):
except TypeError:
# Songid not found
update_item = False
kodicursor.execute("SELECT COALESCE(MAX(idSong),-1) FROM song")
kodicursor.execute("select coalesce(max(idSong),0) from song")
songid = kodicursor.fetchone()[0] + 1
# The song details #####
@ -1747,7 +1746,7 @@ class Music(Items):
# No album found, create a single's album
LOG.info("Failed to add album. Creating singles.")
kodicursor.execute(
"SELECT COALESCE(MAX(idAlbum),-1) FROM album")
"select coalesce(max(idAlbum),0) from album")
albumid = kodicursor.fetchone()[0] + 1
if v.KODIVERSION >= 16:
# Kodi Jarvis

View file

@ -62,7 +62,7 @@ class KodiDBMethods(object):
"""
path_id = self.getPath('plugin://%s.movies/' % v.ADDON_ID)
if path_id is None:
self.cursor.execute("SELECT COALESCE(MAX(idPath),-1) FROM path")
self.cursor.execute("select coalesce(max(idPath),0) from path")
path_id = self.cursor.fetchone()[0] + 1
query = '''
INSERT INTO path(idPath,
@ -82,7 +82,7 @@ class KodiDBMethods(object):
# And TV shows
path_id = self.getPath('plugin://%s.tvshows/' % v.ADDON_ID)
if path_id is None:
self.cursor.execute("SELECT COALESCE(MAX(idPath),-1) FROM path")
self.cursor.execute("select coalesce(max(idPath),0) from path")
path_id = self.cursor.fetchone()[0] + 1
query = '''
INSERT INTO path(idPath,
@ -113,7 +113,7 @@ class KodiDBMethods(object):
parentpath = "%s/" % dirname(dirname(path))
pathid = self.getPath(parentpath)
if pathid is None:
self.cursor.execute("SELECT COALESCE(MAX(idPath),-1) FROM path")
self.cursor.execute("select coalesce(max(idPath),0) from path")
pathid = self.cursor.fetchone()[0] + 1
query = ' '.join((
"INSERT INTO path(idPath, strPath)",
@ -143,7 +143,7 @@ class KodiDBMethods(object):
try:
pathid = self.cursor.fetchone()[0]
except TypeError:
self.cursor.execute("SELECT COALESCE(MAX(idPath),-1) FROM path")
self.cursor.execute("select coalesce(max(idPath),0) from path")
pathid = self.cursor.fetchone()[0] + 1
if strHash is None:
query = (
@ -197,7 +197,7 @@ class KodiDBMethods(object):
try:
fileid = self.cursor.fetchone()[0]
except TypeError:
self.cursor.execute("SELECT COALESCE(MAX(idFile),-1) FROM files")
self.cursor.execute("select coalesce(max(idFile),0) from files")
fileid = self.cursor.fetchone()[0] + 1
query = (
'''
@ -684,7 +684,7 @@ class KodiDBMethods(object):
# Set the resume bookmark
if resume_seconds:
self.cursor.execute(
'SELECT COALESCE(MAX(idBookmark),-1) FROM bookmark')
'select coalesce(max(idBookmark),0) from bookmark')
bookmark_id = self.cursor.fetchone()[0] + 1
query = '''
INSERT INTO bookmark(
@ -721,7 +721,7 @@ class KodiDBMethods(object):
tag_id = self.cursor.fetchone()[0]
except TypeError:
self.cursor.execute("SELECT COALESCE(MAX(tag_id),-1) FROM tag")
self.cursor.execute("select coalesce(max(tag_id),0) from tag")
tag_id = self.cursor.fetchone()[0] + 1
query = "INSERT INTO tag(tag_id, name) values(?, ?)"
@ -772,7 +772,7 @@ class KodiDBMethods(object):
setid = self.cursor.fetchone()[0]
except TypeError:
self.cursor.execute("SELECT COALESCE(MAX(idSet),-1) FROM sets")
self.cursor.execute("select coalesce(max(idSet),0) from sets")
setid = self.cursor.fetchone()[0] + 1
query = "INSERT INTO sets(idSet, strSet) values(?, ?)"
@ -836,9 +836,9 @@ class KodiDBMethods(object):
try:
seasonid = self.cursor.fetchone()[0]
except TypeError:
self.cursor.execute("SELECT COALESCE(MAX(idSeason),-1) FROM seasons")
self.cursor.execute("select coalesce(max(idSeason),0) from seasons")
seasonid = self.cursor.fetchone()[0] + 1
query = "INSERT INTO seasons(idSeason, idShow, season) VALUES(?, ?, ?)"
query = "INSERT INTO seasons(idSeason, idShow, season) values(?, ?, ?)"
self.cursor.execute(query, (seasonid, showid, seasonnumber))
return seasonid
@ -874,10 +874,10 @@ class KodiDBMethods(object):
# [Missing Tag] strMusicBrainzArtistID: Artist Tag Missing
if v.KODIVERSION >= 17:
self.cursor.execute(
"SELECT COALESCE(MAX(idArtist),1) FROM artist")
"select coalesce(max(idArtist),1) from artist")
else:
self.cursor.execute(
"SELECT COALESCE(MAX(idArtist),-1) FROM artist")
"select coalesce(max(idArtist),0) from artist")
artistid = self.cursor.fetchone()[0] + 1
query = (
'''
@ -907,7 +907,7 @@ class KodiDBMethods(object):
albumid = self.cursor.fetchone()[0]
except TypeError:
# Create the album
self.cursor.execute("SELECT COALESCE(MAX(idAlbum),-1) FROM album")
self.cursor.execute("select coalesce(max(idAlbum),0) from album")
albumid = self.cursor.fetchone()[0] + 1
query = (
'''
@ -944,7 +944,7 @@ class KodiDBMethods(object):
genreid = self.cursor.fetchone()[0]
except TypeError:
# Create the genre
self.cursor.execute("SELECT COALESCE(MAX(idGenre),-1) FROM genre")
self.cursor.execute("select coalesce(max(idGenre),0) from genre")
genreid = self.cursor.fetchone()[0] + 1
query = "INSERT INTO genre(idGenre, strGenre) values(?, ?)"
self.cursor.execute(query, (genreid, genre))
@ -975,7 +975,7 @@ class KodiDBMethods(object):
genreid = self.cursor.fetchone()[0]
except TypeError:
# Create the genre
self.cursor.execute("SELECT COALESCE(MAX(idGenre),-1) FROM genre")
self.cursor.execute("select coalesce(max(idGenre),0) from genre")
genreid = self.cursor.fetchone()[0] + 1
query = "INSERT INTO genre(idGenre, strGenre) values(?, ?)"
self.cursor.execute(query, (genreid, genre))
@ -1024,7 +1024,7 @@ class KodiDBMethods(object):
uniqueid = self.cursor.fetchone()[0]
except TypeError:
self.cursor.execute(
'SELECT COALESCE(MAX(uniqueid_id),-1) FROM uniqueid')
'SELECT COALESCE(MAX(uniqueid_id),0) FROM uniqueid')
uniqueid = self.cursor.fetchone()[0] + 1
return uniqueid
@ -1055,7 +1055,7 @@ class KodiDBMethods(object):
try:
ratingid = self.cursor.fetchone()[0]
except TypeError:
self.cursor.execute('SELECT COALESCE(MAX(rating_id),-1) FROM rating')
self.cursor.execute('SELECT COALESCE(MAX(rating_id),0) FROM rating')
ratingid = self.cursor.fetchone()[0] + 1
return ratingid