[tracker] libtracker-data: Move Uri column to separate table



commit 63b0718bd4b0e5b727c9357821b1a6199534f77f
Author: Jürg Billeter <j bitron ch>
Date:   Fri Jan 22 12:41:41 2010 +0100

    libtracker-data: Move Uri column to separate table
    
    Fixes NB#153866.

 src/libtracker-data/tracker-data-manager.c    |   49 +++++-------
 src/libtracker-data/tracker-data-query.c      |    8 +-
 src/libtracker-data/tracker-data-update.c     |  102 +++++++------------------
 src/libtracker-data/tracker-sparql-query.vala |   20 +++---
 4 files changed, 64 insertions(+), 115 deletions(-)
---
diff --git a/src/libtracker-data/tracker-data-manager.c b/src/libtracker-data/tracker-data-manager.c
index c36ffca..f209319 100644
--- a/src/libtracker-data/tracker-data-manager.c
+++ b/src/libtracker-data/tracker-data-manager.c
@@ -389,7 +389,7 @@ query_resource_by_id (gint id)
 	iface = tracker_db_manager_get_db_interface ();
 
 	stmt = tracker_db_interface_create_statement (iface,
-	                                              "SELECT Uri FROM \"rdfs:Resource\" WHERE ID = ?");
+	                                              "SELECT Uri FROM Resource WHERE ID = ?");
 	tracker_db_statement_bind_int (stmt, 0, id);
 	cursor = tracker_db_statement_start_cursor (stmt, NULL);
 	g_object_unref (stmt);
@@ -426,14 +426,12 @@ replay_journal (void)
 			iface = tracker_db_manager_get_db_interface ();
 
 			stmt = tracker_db_interface_create_statement (iface,
-					                              "INSERT  "
-					                              "INTO \"rdfs:Resource\" "
-					                              "(ID, Uri, \"tracker:added\", "
-					                              "\"tracker:modified\", Available) "
-					                              "VALUES (?, ?, ?, 0, 1)");
+					                              "INSERT "
+					                              "INTO Resource "
+					                              "(ID, Uri) "
+					                              "VALUES (?, ?)");
 			tracker_db_statement_bind_int (stmt, 0, id);
 			tracker_db_statement_bind_text (stmt, 1, uri);
-			tracker_db_statement_bind_int64 (stmt, 2, tracker_db_journal_reader_get_time ());
 			tracker_db_statement_execute (stmt, &error);
 		} else if (type == TRACKER_DB_JOURNAL_START_TRANSACTION) {
 			tracker_data_begin_replay_transaction (tracker_db_journal_reader_get_time ());
@@ -496,9 +494,9 @@ class_add_super_classes_from_db (TrackerDBInterface *iface, TrackerClass *class)
 	TrackerDBCursor *cursor;
 
 	stmt = tracker_db_interface_create_statement (iface,
-	                                              "SELECT (SELECT Uri FROM \"rdfs:Resource\" WHERE ID = \"rdfs:subClassOf\") "
+	                                              "SELECT (SELECT Uri FROM Resource WHERE ID = \"rdfs:subClassOf\") "
 	                                              "FROM \"rdfs:Class_rdfs:subClassOf\" "
-	                                              "WHERE ID = (SELECT ID FROM \"rdfs:Resource\" WHERE Uri = ?)");
+	                                              "WHERE ID = (SELECT ID FROM Resource WHERE Uri = ?)");
 	tracker_db_statement_bind_text (stmt, 0, tracker_class_get_uri (class));
 	cursor = tracker_db_statement_start_cursor (stmt, NULL);
 	g_object_unref (stmt);
@@ -524,9 +522,9 @@ property_add_super_properties_from_db (TrackerDBInterface *iface, TrackerPropert
 	TrackerDBCursor *cursor;
 
 	stmt = tracker_db_interface_create_statement (iface,
-	                                              "SELECT (SELECT Uri FROM \"rdfs:Resource\" WHERE ID = \"rdfs:subPropertyOf\") "
+	                                              "SELECT (SELECT Uri FROM Resource WHERE ID = \"rdfs:subPropertyOf\") "
 	                                              "FROM \"rdf:Property_rdfs:subPropertyOf\" "
-	                                              "WHERE ID = (SELECT ID FROM \"rdfs:Resource\" WHERE Uri = ?)");
+	                                              "WHERE ID = (SELECT ID FROM Resource WHERE Uri = ?)");
 	tracker_db_statement_bind_text (stmt, 0, tracker_property_get_uri (property));
 	cursor = tracker_db_statement_start_cursor (stmt, NULL);
 	g_object_unref (stmt);
@@ -553,7 +551,7 @@ db_get_static_data (TrackerDBInterface *iface)
 	TrackerDBResultSet *result_set;
 
 	stmt = tracker_db_interface_create_statement (iface,
-	                                              "SELECT (SELECT Uri FROM \"rdfs:Resource\" WHERE ID = \"tracker:Namespace\".ID), "
+	                                              "SELECT (SELECT Uri FROM Resource WHERE ID = \"tracker:Namespace\".ID), "
 	                                              "\"tracker:prefix\" "
 	                                              "FROM \"tracker:Namespace\"");
 	cursor = tracker_db_statement_start_cursor (stmt, NULL);
@@ -581,7 +579,7 @@ db_get_static_data (TrackerDBInterface *iface)
 	}
 
 	stmt = tracker_db_interface_create_statement (iface,
-	                                              "SELECT \"rdfs:Class\".ID, (SELECT Uri FROM \"rdfs:Resource\" WHERE ID = \"rdfs:Class\".ID) "
+	                                              "SELECT \"rdfs:Class\".ID, (SELECT Uri FROM Resource WHERE ID = \"rdfs:Class\".ID) "
 	                                              "FROM \"rdfs:Class\" ORDER BY ID");
 	cursor = tracker_db_statement_start_cursor (stmt, NULL);
 	g_object_unref (stmt);
@@ -623,16 +621,16 @@ db_get_static_data (TrackerDBInterface *iface)
 	}
 
 	stmt = tracker_db_interface_create_statement (iface,
-	                                              "SELECT \"rdf:Property\".ID, (SELECT Uri FROM \"rdfs:Resource\" WHERE ID = \"rdf:Property\".ID), "
-	                                              "(SELECT Uri FROM \"rdfs:Resource\" WHERE ID = \"rdfs:domain\"), "
-	                                              "(SELECT Uri FROM \"rdfs:Resource\" WHERE ID = \"rdfs:range\"), "
+	                                              "SELECT \"rdf:Property\".ID, (SELECT Uri FROM Resource WHERE ID = \"rdf:Property\".ID), "
+	                                              "(SELECT Uri FROM Resource WHERE ID = \"rdfs:domain\"), "
+	                                              "(SELECT Uri FROM Resource WHERE ID = \"rdfs:range\"), "
 	                                              "\"nrl:maxCardinality\", "
 	                                              "\"tracker:indexed\", "
 	                                              "\"tracker:fulltextIndexed\", "
 	                                              "\"tracker:transient\", "
 	                                              "\"tracker:isAnnotation\", "
 	                                              "(SELECT 1 FROM \"rdfs:Resource_rdf:type\" WHERE ID = \"rdf:Property\".ID AND "
-	                                              "\"rdf:type\" = (Select ID FROM \"rdfs:Resource\" WHERE Uri = '" NRL_INVERSE_FUNCTIONAL_PROPERTY "')) "
+	                                              "\"rdf:type\" = (SELECT ID FROM Resource WHERE Uri = '" NRL_INVERSE_FUNCTIONAL_PROPERTY "')) "
 	                                              "FROM \"rdf:Property\" ORDER BY ID");
 	cursor = tracker_db_statement_start_cursor (stmt, NULL);
 	g_object_unref (stmt);
@@ -748,14 +746,12 @@ insert_uri_in_resource_table (TrackerDBInterface *iface,
 	GError *error = NULL;
 
 	stmt = tracker_db_interface_create_statement (iface,
-	                                              "INSERT  "
-	                                              "INTO \"rdfs:Resource\" "
-	                                              "(ID, Uri, \"tracker:added\", "
-	                                              "\"tracker:modified\", Available) "
-	                                              "VALUES (?, ?, ?, 0, 1)");
+	                                              "INSERT "
+	                                              "INTO Resource "
+	                                              "(ID, Uri) "
+	                                              "VALUES (?, ?)");
 	tracker_db_statement_bind_int (stmt, 0, id);
 	tracker_db_statement_bind_text (stmt, 1, uri);
-	tracker_db_statement_bind_int64 (stmt, 2, (gint64) time (NULL));
 	tracker_db_statement_execute (stmt, &error);
 
 	if (error) {
@@ -873,7 +869,9 @@ create_decomposed_metadata_tables (TrackerDBInterface *iface,
 	sql = g_string_new ("");
 	g_string_append_printf (sql, "CREATE TABLE \"%s\" (ID INTEGER NOT NULL PRIMARY KEY", service_name);
 	if (main_class) {
-		g_string_append (sql, ", Uri TEXT NOT NULL, Available INTEGER NOT NULL");
+		tracker_db_interface_execute_query (iface, NULL, "CREATE TABLE Resource (ID INTEGER NOT NULL PRIMARY KEY, Uri Text NOT NULL, UNIQUE (Uri))");
+
+		g_string_append (sql, ", Available INTEGER NOT NULL");
 	}
 
 	properties = tracker_ontology_get_properties (&n_props);
@@ -904,9 +902,6 @@ create_decomposed_metadata_tables (TrackerDBInterface *iface,
 		}
 	}
 
-	if (main_class) {
-		g_string_append (sql, ", UNIQUE (Uri)");
-	}
 	g_string_append (sql, ")");
 	tracker_db_interface_execute_query (iface, NULL, "%s", sql->str);
 
diff --git a/src/libtracker-data/tracker-data-query.c b/src/libtracker-data/tracker-data-query.c
index 0b9f86d..164dcb2 100644
--- a/src/libtracker-data/tracker-data-query.c
+++ b/src/libtracker-data/tracker-data-query.c
@@ -46,11 +46,9 @@ tracker_data_query_rdf_type (gint id)
 	iface = tracker_db_manager_get_db_interface ();
 
 	stmt = tracker_db_interface_create_statement (iface,
-	                                              "SELECT \"rdfs:Resource\".\"Uri\" "
+	                                              "SELECT (SELECT Uri FROM Resource WHERE ID = \"rdf:type\") "
 	                                              "FROM \"rdfs:Resource_rdf:type\" "
-	                                              "INNER JOIN \"rdfs:Resource\" "
-	                                              "ON \"rdfs:Resource_rdf:type\".\"rdf:type\" = \"rdfs:Resource\".\"ID\" "
-	                                              "WHERE \"rdfs:Resource_rdf:type\".\"ID\" = ?");
+	                                              "WHERE ID = ?");
 
 	tracker_db_statement_bind_int (stmt, 0, id);
 	cursor = tracker_db_statement_start_cursor (stmt, NULL);
@@ -85,7 +83,7 @@ tracker_data_query_resource_id (const gchar *uri)
 	iface = tracker_db_manager_get_db_interface ();
 
 	stmt = tracker_db_interface_create_statement (iface,
-	                                              "SELECT ID FROM \"rdfs:Resource\" WHERE Uri = ?");
+	                                              "SELECT ID FROM Resource WHERE Uri = ?");
 	tracker_db_statement_bind_text (stmt, 0, uri);
 	cursor = tracker_db_statement_start_cursor (stmt, NULL);
 	g_object_unref (stmt);
diff --git a/src/libtracker-data/tracker-data-update.c b/src/libtracker-data/tracker-data-update.c
index 04a5366..001fd6c 100644
--- a/src/libtracker-data/tracker-data-update.c
+++ b/src/libtracker-data/tracker-data-update.c
@@ -212,7 +212,7 @@ tracker_data_update_get_new_service_id (TrackerDBInterface *iface)
 	temp_iface = tracker_db_manager_get_db_interface ();
 
 	stmt = tracker_db_interface_create_statement (temp_iface,
-	                                              "SELECT MAX(ID) AS A FROM \"rdfs:Resource\"");
+	                                              "SELECT MAX(ID) AS A FROM Resource");
 	cursor = tracker_db_statement_start_cursor (stmt, NULL);
 	g_object_unref (stmt);
 
@@ -394,12 +394,9 @@ ensure_resource_id (const gchar *uri,
 		iface = tracker_db_manager_get_db_interface ();
 
 		id = tracker_data_update_get_new_service_id (common);
-		stmt = tracker_db_interface_create_statement (iface, "INSERT INTO \"rdfs:Resource\" (ID, Uri, \"tracker:added\", \"tracker:modified\", Available) VALUES (?, ?, ?, ?, 1)");
+		stmt = tracker_db_interface_create_statement (iface, "INSERT INTO Resource (ID, Uri) VALUES (?, ?)");
 		tracker_db_statement_bind_int (stmt, 0, id);
 		tracker_db_statement_bind_text (stmt, 1, uri);
-		g_warn_if_fail  (resource_time != 0);
-		tracker_db_statement_bind_int64 (stmt, 2, (gint64) resource_time);
-		tracker_db_statement_bind_int (stmt, 3, tracker_data_update_get_next_modseq ());
 		tracker_db_statement_execute (stmt, NULL);
 		g_object_unref (stmt);
 
@@ -455,7 +452,7 @@ tracker_data_resource_buffer_flush (GError **error)
 	if (resource_buffer->new_subject != NULL) {
 		/* change uri of resource */
 		stmt = tracker_db_interface_create_statement (iface,
-		                                              "UPDATE \"rdfs:Resource\" SET Uri = ? WHERE ID = ?");
+		                                              "UPDATE Resource SET Uri = ? WHERE ID = ?");
 		tracker_db_statement_bind_text (stmt, 0, resource_buffer->new_subject);
 		tracker_db_statement_bind_int (stmt, 1, resource_buffer->id);
 		tracker_db_statement_execute (stmt, &actual_error);
@@ -517,60 +514,6 @@ tracker_data_resource_buffer_flush (GError **error)
 					tracker_class_set_count (table->class, tracker_class_get_count (table->class) - 1);
 				}
 
-				if (strcmp (table_name, "rdfs:Resource") == 0) {
-					TrackerProperty **properties, *property;
-					guint n_props;
-					gboolean first;
-
-					/* never delete Uri <-> ID mapping to avoid dangling references,
-					   do remove property values, though */
-
-					sql = g_string_new ("UPDATE \"rdfs:Resource\" SET");
-					first = TRUE;
-
-					properties = tracker_ontology_get_properties (&n_props);
-					for (i = 0; i < n_props; i++) {
-						property = properties[i];
-
-						if (tracker_property_get_multiple_values (property)) {
-							continue;
-						}
-
-						if (strcmp (tracker_class_get_name (tracker_property_get_domain (property)), table_name) == 0) {
-							if (strcmp (tracker_property_get_name (property), "tracker:added") == 0 ||
-							    strcmp (tracker_property_get_name (property), "tracker:modified") == 0) {
-								/* do not touch tracker:added or tracker:modified */
-								continue;
-							}
-
-							/* set all other property columns to NULL */
-							if (first) {
-								first = FALSE;
-							} else {
-								g_string_append (sql, ",");
-							}
-							g_string_append_printf (sql, " \"%s\" = NULL",
-										tracker_property_get_name (property));
-						}
-					}
-
-					g_string_append (sql, " WHERE ID = ?");
-
-					stmt = tracker_db_interface_create_statement (iface, "%s", sql->str);
-					tracker_db_statement_bind_int (stmt, 0, resource_buffer->id);
-					tracker_db_statement_execute (stmt, &actual_error);
-					g_object_unref (stmt);
-
-					g_string_free (sql, TRUE);
-
-					if (actual_error) {
-						g_propagate_error (error, actual_error);
-						return;
-					}
-
-					continue;
-				}
-
 				/* remove row from class table */
 				stmt = tracker_db_interface_create_statement (iface, "DELETE FROM \"%s\" WHERE ID = ?", table_name);
 				tracker_db_statement_bind_int (stmt, 0, resource_buffer->id);
@@ -586,13 +529,26 @@ tracker_data_resource_buffer_flush (GError **error)
 			}
 
 			if (table->insert) {
-				/* ensure we have a row for the subject id */
-				stmt = tracker_db_interface_create_statement (iface,
-				                                              "INSERT OR IGNORE INTO \"%s\" (ID) VALUES (?)",
-				                                              table_name);
-				tracker_db_statement_bind_int (stmt, 0, resource_buffer->id);
-				tracker_db_statement_execute (stmt, &actual_error);
-				g_object_unref (stmt);
+				if (strcmp (table_name, "rdfs:Resource") == 0) {
+					/* ensure we have a row for the subject id */
+					stmt = tracker_db_interface_create_statement (iface,
+						                                      "INSERT OR IGNORE INTO \"%s\" (ID, \"tracker:added\", \"tracker:modified\", Available) VALUES (?, ?, ?, 1)",
+						                                      table_name);
+					tracker_db_statement_bind_int (stmt, 0, resource_buffer->id);
+					g_warn_if_fail  (resource_time != 0);
+					tracker_db_statement_bind_int64 (stmt, 1, (gint64) resource_time);
+					tracker_db_statement_bind_int (stmt, 3, tracker_data_update_get_next_modseq ());
+					tracker_db_statement_execute (stmt, &actual_error);
+					g_object_unref (stmt);
+				} else {
+					/* ensure we have a row for the subject id */
+					stmt = tracker_db_interface_create_statement (iface,
+						                                      "INSERT OR IGNORE INTO \"%s\" (ID) VALUES (?)",
+						                                      table_name);
+					tracker_db_statement_bind_int (stmt, 0, resource_buffer->id);
+					tracker_db_statement_execute (stmt, &actual_error);
+					g_object_unref (stmt);
+				}
 
 				if (actual_error) {
 					g_propagate_error (error, actual_error);
@@ -1216,9 +1172,9 @@ cache_delete_resource_type (TrackerClass *class,
 	/* retrieve all subclasses we need to remove from the subject
 	 * before we can remove the class specified as object of the statement */
 	stmt = tracker_db_interface_create_statement (iface,
-	                                              "SELECT (SELECT Uri FROM \"rdfs:Resource\" WHERE ID = \"rdfs:Class_rdfs:subClassOf\".ID) "
+	                                              "SELECT (SELECT Uri FROM Resource WHERE ID = \"rdfs:Class_rdfs:subClassOf\".ID) "
 	                                              "FROM \"rdfs:Resource_rdf:type\" INNER JOIN \"rdfs:Class_rdfs:subClassOf\" ON (\"rdf:type\" = \"rdfs:Class_rdfs:subClassOf\".ID) "
-	                                              "WHERE \"rdfs:Resource_rdf:type\".ID = ? AND \"rdfs:subClassOf\" = (SELECT ID FROM \"rdfs:Resource\" WHERE Uri = ?)");
+	                                              "WHERE \"rdfs:Resource_rdf:type\".ID = ? AND \"rdfs:subClassOf\" = (SELECT ID FROM Resource WHERE Uri = ?)");
 	tracker_db_statement_bind_int (stmt, 0, resource_buffer->id);
 	tracker_db_statement_bind_text (stmt, 1, tracker_class_get_uri (class));
 	result_set = tracker_db_statement_execute (stmt, NULL);
@@ -1693,7 +1649,7 @@ db_set_volume_available (const gchar *uri,
 
 	iface = tracker_db_manager_get_db_interface ();
 
-	stmt = tracker_db_interface_create_statement (iface, "UPDATE \"rdfs:Resource\" SET Available = ? WHERE ID IN (SELECT ID FROM \"nie:DataObject\" WHERE \"nie:dataSource\" IN (SELECT ID FROM \"rdfs:Resource\" WHERE Uri = ?))");
+	stmt = tracker_db_interface_create_statement (iface, "UPDATE \"rdfs:Resource\" SET Available = ? WHERE ID IN (SELECT ID FROM \"nie:DataObject\" WHERE \"nie:dataSource\" IN (SELECT ID FROM Resource WHERE Uri = ?))");
 	tracker_db_statement_bind_int (stmt, 0, available ? 1 : 0);
 	tracker_db_statement_bind_text (stmt, 1, uri);
 	tracker_db_statement_execute (stmt, NULL);
@@ -1865,7 +1821,7 @@ tracker_data_update_disable_all_volumes (void)
 	                                              "WHERE ID IN ("
 	                                              "SELECT ID FROM \"nie:DataObject\" "
 	                                              "WHERE \"nie:dataSource\" IN ("
-	                                              "SELECT ID FROM \"rdfs:Resource\" WHERE Uri != ?"
+	                                              "SELECT ID FROM Resource WHERE Uri != ?"
 	                                              ")"
 	                                              ")");
 	tracker_db_statement_bind_text (stmt, 0, TRACKER_NON_REMOVABLE_MEDIA_DATASOURCE_URN);
@@ -1972,7 +1928,7 @@ format_sql_value_as_string (GString         *sql,
 {
 	switch (tracker_property_get_data_type (property)) {
 	case TRACKER_PROPERTY_TYPE_RESOURCE:
-		g_string_append_printf (sql, "(SELECT Uri FROM \"rdfs:Resource\" WHERE ID = \"%s\")", tracker_property_get_name (property));
+		g_string_append_printf (sql, "(SELECT Uri FROM Resource WHERE ID = \"%s\")", tracker_property_get_name (property));
 		break;
 	case TRACKER_PROPERTY_TYPE_INTEGER:
 	case TRACKER_PROPERTY_TYPE_DOUBLE:
@@ -2020,7 +1976,7 @@ tracker_data_delete_resource_description (const gchar *graph,
 
 	properties = tracker_ontology_get_properties (&n_props);
 
-	stmt = tracker_db_interface_create_statement (iface, "SELECT (SELECT Uri FROM \"rdfs:Resource\" WHERE ID = \"rdf:type\") FROM \"rdfs:Resource_rdf:type\" WHERE ID = ?");
+	stmt = tracker_db_interface_create_statement (iface, "SELECT (SELECT Uri FROM Resource WHERE ID = \"rdf:type\") FROM \"rdfs:Resource_rdf:type\" WHERE ID = ?");
 	tracker_db_statement_bind_int (stmt, 0, resource_id);
 	result_set = tracker_db_statement_execute (stmt, NULL);
 	g_object_unref (stmt);
diff --git a/src/libtracker-data/tracker-sparql-query.vala b/src/libtracker-data/tracker-sparql-query.vala
index 262e159..88ae9d8 100644
--- a/src/libtracker-data/tracker-sparql-query.vala
+++ b/src/libtracker-data/tracker-sparql-query.vala
@@ -109,7 +109,7 @@ public class Tracker.SparqlQuery : Object {
 				DBResultSet result_set = null;
 				if (subject_id > 0) {
 					var iface = DBManager.get_db_interface ();
-					var stmt = iface.create_statement ("SELECT (SELECT Uri FROM \"rdfs:Resource\" WHERE ID = \"rdf:type\") FROM \"rdfs:Resource_rdf:type\" WHERE ID = ?");
+					var stmt = iface.create_statement ("SELECT (SELECT Uri FROM Resource WHERE ID = \"rdf:type\") FROM \"rdfs:Resource_rdf:type\" WHERE ID = ?");
 					stmt.bind_int (0, subject_id);
 					result_set = stmt.execute ();
 				}
@@ -128,7 +128,7 @@ public class Tracker.SparqlQuery : Object {
 								} else {
 									sql.append (" UNION ALL ");
 								}
-								sql.append_printf ("SELECT ID, (SELECT ID FROM \"rdfs:Resource\" WHERE Uri = '%s') AS \"predicate\", ", prop.uri);
+								sql.append_printf ("SELECT ID, (SELECT ID FROM Resource WHERE Uri = '%s') AS \"predicate\", ", prop.uri);
 
 								append_expression_as_string (sql, "\"%s\"".printf (prop.name), prop.data_type);
 
@@ -157,7 +157,7 @@ public class Tracker.SparqlQuery : Object {
 				var object_id = Data.query_resource_id (object);
 
 				var iface = DBManager.get_db_interface ();
-				var stmt = iface.create_statement ("SELECT (SELECT Uri FROM \"rdfs:Resource\" WHERE ID = \"rdf:type\") FROM \"rdfs:Resource_rdf:type\" WHERE ID = ?");
+				var stmt = iface.create_statement ("SELECT (SELECT Uri FROM Resource WHERE ID = \"rdf:type\") FROM \"rdfs:Resource_rdf:type\" WHERE ID = ?");
 				stmt.bind_int (0, object_id);
 				var result_set = stmt.execute ();
 
@@ -175,7 +175,7 @@ public class Tracker.SparqlQuery : Object {
 								} else {
 									sql.append (" UNION ALL ");
 								}
-								sql.append_printf ("SELECT ID, (SELECT ID FROM \"rdfs:Resource\" WHERE Uri = '%s') AS \"predicate\", ", prop.uri);
+								sql.append_printf ("SELECT ID, (SELECT ID FROM Resource WHERE Uri = '%s') AS \"predicate\", ", prop.uri);
 
 								append_expression_as_string (sql, "\"%s\"".printf (prop.name), prop.data_type);
 
@@ -202,7 +202,7 @@ public class Tracker.SparqlQuery : Object {
 						} else {
 							sql.append (" UNION ALL ");
 						}
-						sql.append_printf ("SELECT ID, (SELECT ID FROM \"rdfs:Resource\" WHERE Uri = '%s') AS \"predicate\", ", prop.uri);
+						sql.append_printf ("SELECT ID, (SELECT ID FROM Resource WHERE Uri = '%s') AS \"predicate\", ", prop.uri);
 
 						append_expression_as_string (sql, "\"%s\"".printf (prop.name), prop.data_type);
 
@@ -888,7 +888,7 @@ public class Tracker.SparqlQuery : Object {
 		long begin = sql.len;
 		if (translate_expression (sql) == PropertyType.RESOURCE) {
 			// ID => Uri
-			sql.insert (begin, "(SELECT Uri FROM \"rdfs:Resource\" WHERE ID = ");
+			sql.insert (begin, "(SELECT Uri FROM Resource WHERE ID = ");
 			sql.append (")");
 		}
 	}
@@ -1238,7 +1238,7 @@ public class Tracker.SparqlQuery : Object {
 			break;
 		case PropertyType.RESOURCE:
 			// ID => Uri
-			sql.insert (begin, "(SELECT Uri FROM \"rdfs:Resource\" WHERE ID = ");
+			sql.insert (begin, "(SELECT Uri FROM Resource WHERE ID = ");
 			sql.append (")");
 			break;
 		case PropertyType.BOOLEAN:
@@ -1337,7 +1337,7 @@ public class Tracker.SparqlQuery : Object {
 				throw get_error ("Invalid FILTER");
 			}
 
-			sql.append ("(SELECT ID FROM \"rdfs:Resource\" WHERE Uri = ?)");
+			sql.append ("(SELECT ID FROM Resource WHERE Uri = ?)");
 
 			var new_binding = new LiteralBinding ();
 			new_binding.literal = variable.binding.type.uri;
@@ -1531,7 +1531,7 @@ public class Tracker.SparqlQuery : Object {
 			return result;
 		} else {
 			// resource
-			sql.append ("(SELECT ID FROM \"rdfs:Resource\" WHERE Uri = ?)");
+			sql.append ("(SELECT ID FROM Resource WHERE Uri = ?)");
 			var binding = new LiteralBinding ();
 			binding.literal = uri;
 			bindings.append (binding);
@@ -2197,7 +2197,7 @@ public class Tracker.SparqlQuery : Object {
 			} else {
 				sql.append (" = ");
 				if (binding.data_type == PropertyType.RESOURCE) {
-					sql.append ("(SELECT ID FROM \"rdfs:Resource\" WHERE Uri = ?)");
+					sql.append ("(SELECT ID FROM Resource WHERE Uri = ?)");
 				} else {
 					sql.append ("?");
 				}



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