Commit 790efc98 authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

Ensure we don't have leftover columns after loading

This will prevent fetching useless fields, and potentially off by 1 or
more when loading entities after a database change
parent beb7efee
Pipeline #7523 passed with stage
in 17 minutes and 38 seconds
......@@ -56,6 +56,7 @@ Album::Album(MediaLibraryPtr ml, sqlite::Row& row)
, m_nbDiscs( row.extract<decltype(m_nbDiscs)>() )
, m_isPresent( row.extract<decltype(m_isPresent)>() )
{
assert( row.hasRemainingColumns() == false );
}
Album::Album( MediaLibraryPtr ml, const std::string& title, int64_t thumbnailId )
......
......@@ -50,6 +50,7 @@ Artist::Artist( MediaLibraryPtr ml, sqlite::Row& row )
, m_mbId( row.extract<decltype(m_mbId)>() )
, m_isPresent( row.extract<decltype(m_isPresent)>() )
{
assert( row.hasRemainingColumns() == false );
}
Artist::Artist( MediaLibraryPtr ml, const std::string& name )
......
......@@ -46,6 +46,7 @@ AudioTrack::AudioTrack( MediaLibraryPtr, sqlite::Row& row )
, m_description( row.extract<decltype(m_description)>() )
, m_mediaId( row.extract<decltype(m_mediaId)>() )
{
assert( row.hasRemainingColumns() == false );
}
AudioTrack::AudioTrack( MediaLibraryPtr, const std::string& codec, unsigned int bitrate, unsigned int sampleRate,
......
......@@ -105,6 +105,9 @@ Chapter::Chapter( MediaLibraryPtr ml, sqlite::Row& row )
, m_duration( row.extract<decltype(m_offset)>() )
, m_name( row.extract<decltype(m_name)>() )
{
// Simply check that the media_id row is present, until we eventually store it
assert( row.extract<int64_t>() );
assert( row.hasRemainingColumns() == false );
}
Chapter::Chapter( MediaLibraryPtr ml, int64_t offset, int64_t duration,
......
......@@ -43,6 +43,7 @@ Device::Device( MediaLibraryPtr ml, sqlite::Row& row )
, m_isPresent( row.extract<decltype(m_isPresent)>() )
, m_lastSeen( row.extract<decltype(m_lastSeen)>() )
{
assert( row.hasRemainingColumns() == false );
}
Device::Device( MediaLibraryPtr ml, const std::string& uuid,
......
......@@ -52,6 +52,7 @@ File::File( MediaLibraryPtr ml, sqlite::Row& row )
, m_isExternal( row.extract<decltype(m_isExternal)>() )
, m_isNetwork( row.extract<decltype(m_isNetwork)>() )
{
assert( row.hasRemainingColumns() == false );
}
File::File( MediaLibraryPtr ml, int64_t mediaId, int64_t playlistId, Type type,
......
......@@ -45,6 +45,7 @@ Genre::Genre( MediaLibraryPtr ml, sqlite::Row& row )
, m_name( row.extract<decltype(m_name)>() )
, m_nbTracks( row.extract<decltype(m_nbTracks)>() )
{
assert( row.hasRemainingColumns() == false );
}
Genre::Genre( MediaLibraryPtr ml, const std::string& name )
......
......@@ -45,6 +45,7 @@ Label::Label(MediaLibraryPtr ml, sqlite::Row& row )
, m_id( row.extract<decltype(m_id)>() )
, m_name( row.extract<decltype (m_name)>() )
{
assert( row.hasRemainingColumns() == false );
}
Label::Label( MediaLibraryPtr ml, const std::string& name )
......
......@@ -86,6 +86,7 @@ Media::Media( MediaLibraryPtr ml, sqlite::Row& row )
, m_metadata( m_ml, IMetadata::EntityType::Media )
, m_changed( false )
{
assert( row.nbColumns() == 17 );
}
Media::Media( MediaLibraryPtr ml, const std::string& title, Type type,
......
......@@ -43,6 +43,7 @@ Movie::Movie(MediaLibraryPtr ml, sqlite::Row& row )
, m_summary( row.extract<decltype(m_summary)>() )
, m_imdbId( row.extract<decltype(m_imdbId)>() )
{
assert( row.hasRemainingColumns() == false );
}
Movie::Movie( MediaLibraryPtr ml, int64_t mediaId )
......
......@@ -47,6 +47,7 @@ Playlist::Playlist( MediaLibraryPtr ml, sqlite::Row& row )
, m_creationDate( row.extract<decltype(m_creationDate)>() )
, m_artworkMrl( row.extract<decltype(m_artworkMrl)>() )
{
assert( row.hasRemainingColumns() == false );
}
Playlist::Playlist( MediaLibraryPtr ml, const std::string& name )
......
......@@ -49,6 +49,7 @@ Show::Show( MediaLibraryPtr ml, sqlite::Row& row )
, m_artworkMrl( row.extract<decltype(m_artworkMrl)>() )
, m_tvdbId( row.extract<decltype(m_tvdbId)>() )
{
assert( row.hasRemainingColumns() == false );
}
Show::Show( MediaLibraryPtr ml, const std::string& name )
......
......@@ -47,6 +47,7 @@ ShowEpisode::ShowEpisode( MediaLibraryPtr ml, sqlite::Row& row )
, m_tvdbId( row.extract<decltype(m_tvdbId)>() )
, m_showId( row.extract<decltype(m_showId)>() )
{
assert( row.hasRemainingColumns() == false );
}
ShowEpisode::ShowEpisode( MediaLibraryPtr ml, int64_t mediaId,
......
......@@ -42,6 +42,9 @@ SubtitleTrack::SubtitleTrack( MediaLibraryPtr, sqlite::Row& row )
, m_description( row.extract<decltype(m_description)>() )
, m_encoding( row.extract<decltype(m_encoding)>() )
{
// Ensure there is a media id to load
assert( row.extract<int64_t>() );
assert( row.hasRemainingColumns() == false );
}
SubtitleTrack::SubtitleTrack( MediaLibraryPtr, std::string codec,
......
......@@ -43,6 +43,7 @@ Thumbnail::Thumbnail( MediaLibraryPtr ml, sqlite::Row& row )
, m_origin( row.extract<decltype(m_origin)>() )
, m_isOwned( row.extract<decltype(m_isOwned)>() )
{
assert( row.hasRemainingColumns() == false );
// If the thumbnail was generated by the medialibrary, we store it as a
// relative path, from the user provided workspace
if ( m_isOwned == true )
......
......@@ -48,6 +48,7 @@ VideoTrack::VideoTrack( MediaLibraryPtr, sqlite::Row& row )
, m_language( row.extract<decltype(m_language)>() )
, m_description( row.extract<decltype(m_description)>() )
{
assert( row.hasRemainingColumns() == false );
}
VideoTrack::VideoTrack( MediaLibraryPtr, const std::string& codec, unsigned int width,
......
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