Commit 9ecfc564 authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

Media: Ensure subType isn't null

parent 486900fd
......@@ -571,7 +571,9 @@ void Media::createTable( sqlite::Connection* connection )
std::string req = "CREATE TABLE IF NOT EXISTS " + policy::MediaTable::Name + "("
"id_media INTEGER PRIMARY KEY AUTOINCREMENT,"
"type INTEGER,"
"subtype INTEGER,"
"subtype INTEGER NOT NULL DEFAULT " +
std::to_string( static_cast<typename std::underlying_type<IMedia::SubType>::type>(
IMedia::SubType::Unknown ) ) + ","
"duration INTEGER DEFAULT -1,"
"play_count UNSIGNED INTEGER,"
"last_played_date UNSIGNED INTEGER,"
......
......@@ -27,7 +27,9 @@
"CREATE TABLE " + MediaTable::Name + "("
"id_media INTEGER PRIMARY KEY AUTOINCREMENT,"
"type INTEGER,"
"subtype INTEGER,"
"subtype INTEGER NOT NULL DEFAULT " +
std::to_string( static_cast<typename std::underlying_type<IMedia::SubType>::type>(
IMedia::SubType::Unknown ) ) + ","
"duration INTEGER DEFAULT -1,"
"play_count UNSIGNED INTEGER,"
"last_played_date UNSIGNED INTEGER,"
......@@ -47,7 +49,10 @@
"id_media, type, subtype, duration, play_count, last_played_date, insertion_date,"
"release_date, thumbnail_id, thumbnail_generated, title, filename, is_favorite,"
"is_present) "
"SELECT id_media, type, subtype, duration, play_count, last_played_date,"
"SELECT id_media, type, ifnull(subtype, " +
std::to_string( static_cast<typename std::underlying_type<IMedia::SubType>::type>(
IMedia::SubType::Unknown ) )
+ "), duration, play_count, last_played_date,"
"insertion_date, release_date, "
"CASE thumbnail WHEN NULL THEN 0 WHEN '' THEN 0 ELSE id_media END,"
"CASE thumbnail WHEN NULL THEN 0 WHEN '' THEN 0 ELSE 1 END,"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment