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

Media: Fix reference to ambiguous column

"Failed to compile/prepare request [SELECT COUNT(DISTINCT id_media ) FROM Media m  LEFT JOIN File f ON m.id_media = f.media_id  WHERE folder_id = ?]: ambiguous column name: folder_id(1)"

(cherry picked from commit bf294a38)
Signed-off-by: 's avatarHugo Beauzée-Luyssen <hugo@beauzee.fr>
parent 964c6dfa
Pipeline #4008 passed with stages
in 11 minutes and 55 seconds
......@@ -941,10 +941,10 @@ Query<IMedia> Media::fromFolderId( MediaLibraryPtr ml, IMedia::Type type,
// manipulated when the device is not present
std::string req = "FROM " + Table::Name + " m ";
req += addRequestJoin( params, false, false );
req += " WHERE folder_id = ?";
req += " WHERE m.folder_id = ?";
if ( type != Type::Unknown )
{
req += " AND type = ?";
req += " AND m.type = ?";
return make_query<Media, IMedia>( ml, "*", req, sortRequest( params ),
folderId, type );
}
......
......@@ -646,6 +646,16 @@ TEST_F( FoldersNoDiscover, ListWithMedia )
mediaQuery = folders[0]->media( IMedia::Type::Unknown, nullptr );
ASSERT_EQ( 2u, mediaQuery->count() );
ASSERT_EQ( 2u, mediaQuery->all().size() );
// Now try sorting by last modified date, which was causing a crash
params.sort = SortingCriteria::LastModificationDate;
mediaQuery = folders[0]->media( IMedia::Type::Unknown, &params );
ASSERT_EQ( 2u, mediaQuery->count() );
ASSERT_EQ( 2u, mediaQuery->all().size() );
mediaQuery = folders[0]->media( IMedia::Type::Audio, &params );
ASSERT_EQ( 1u, mediaQuery->count() );
ASSERT_EQ( 1u, mediaQuery->all().size() );
}
TEST_F( FoldersNoDiscover, ListSubFolders )
......
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