[tracker/tracker-0.6] Fixes: NB#123591, Unknown genre displayed twice for the attached clips



commit 5bd992d93af3142ec776993d97a60da484750cae
Author: Martyn Russell <martyn imendio com>
Date:   Tue Jun 23 17:06:28 2009 +0100

    Fixes: NB#123591, Unknown genre displayed twice for the attached clips
    
    Nasty bug, we were setting Text entries to '' not NULL and also not
    setting the KeyMetadataCollation columns either which caused strange
    results when we group and order by them - since the collated data is
    then stale but still used.

 src/libtracker-data/tracker-data-update.c |   32 +++++++++++++++++++++++++---
 1 files changed, 28 insertions(+), 4 deletions(-)
---
diff --git a/src/libtracker-data/tracker-data-update.c b/src/libtracker-data/tracker-data-update.c
index 61bca90..a455423 100644
--- a/src/libtracker-data/tracker-data-update.c
+++ b/src/libtracker-data/tracker-data-update.c
@@ -453,7 +453,9 @@ tracker_data_update_delete_metadata (TrackerService *service,
 				     const gchar    *value)
 {
 	TrackerDBInterface *iface;
+	GString *s = NULL;
 	gint metadata_key;
+	gint collate_key;
 	gchar *id_str;
 
 	id_str = tracker_guint32_to_string (service_id);
@@ -510,15 +512,37 @@ tracker_data_update_delete_metadata (TrackerService *service,
 		break;
 	}
 
+	g_free (id_str);
+
 	metadata_key = tracker_ontology_service_get_key_metadata (tracker_service_get_name (service),
 								  tracker_field_get_name (field));
+	collate_key = tracker_ontology_service_get_key_collate (tracker_service_get_name (service),
+								tracker_field_get_name (field));
+
+	/* Try to do these together if we can, saves time */
 	if (metadata_key > 0) {
-		tracker_db_interface_execute_query (iface, NULL,
-						    "update Services set KeyMetadata%d = '%s' where id = %d",
-						    metadata_key, "", service_id);
+		s = g_string_new ("");
+		g_string_append_printf (s, "KeyMetadata%d = NULL", metadata_key);
 	}
 
-	g_free (id_str);
+	if (collate_key > 0) {
+		if (!s) {
+			s = g_string_new ("");
+		} else {
+			g_string_append (s, ", ");
+		}
+
+		g_string_append_printf (s, "KeyMetadataCollation%d = NULL", collate_key);
+	}
+
+	if (s) {
+		tracker_db_interface_execute_query (iface, NULL,
+						    "UPDATE Services SET %s WHERE id = %d",
+						    s->str, 
+						    service_id);
+
+		g_string_free (s, TRUE);
+	}
 }
 
 void



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]