Skip to content
This repository
Browse code

[pvr] work around for frodo to fix CPVRDatabase::RemoveStaleChannelsF…

…romGroup for both sqlite3 and mysql
  • Loading branch information...
commit f70eb43ebc8ed2475296ff997214cc56fccce531 1 parent 2833a67
Lars Op den Kamp authored January 11, 2013 S. Davilla committed January 11, 2013

Showing 1 changed file with 13 additions and 2 deletions. Show diff stats Hide diff stats

  1. 15  xbmc/pvr/PVRDatabase.cpp
15  xbmc/pvr/PVRDatabase.cpp
@@ -609,8 +609,19 @@ bool CPVRDatabase::RemoveStaleChannelsFromGroup(const CPVRChannelGroup &group)
609 609
   if (!group.IsInternalGroup())
610 610
   {
611 611
     /* First remove channels that don't exist in the main channels table */
612  
-    CStdString strQuery = FormatSQL("DELETE m FROM map_channelgroups_channels m LEFT JOIN channels c ON (c.idChannel = m.idChannel) WHERE c.idChannel IS NULL");
613  
-    bDelete = ExecuteQuery(strQuery);
  612
+
  613
+    // XXX work around for frodo: fix this up so it uses one query for all db types
  614
+    // mysql doesn't support subqueries when deleting and sqlite doesn't support joins when deleting
  615
+    if (g_advancedSettings.m_databaseTV.type.Equals("mysql"))
  616
+    {
  617
+      CStdString strQuery = FormatSQL("DELETE m FROM map_channelgroups_channels m LEFT JOIN channels c ON (c.idChannel = m.idChannel) WHERE c.idChannel IS NULL");
  618
+      bDelete = ExecuteQuery(strQuery);
  619
+    }
  620
+    else
  621
+    {
  622
+      CStdString strWhereClause = FormatSQL("idChannel IN (SELECT m.idChannel FROM map_channelgroups_channels m LEFT JOIN channels on m.idChannel = channels.idChannel WHERE channels.idChannel IS NULL)");
  623
+      bDelete = DeleteValues("map_channelgroups_channels", strWhereClause);
  624
+    }
614 625
   }
615 626
 
616 627
   if (group.m_members.size() > 0)

0 notes on commit f70eb43

Please sign in to comment.
Something went wrong with that request. Please try again.