[tracker/sparql-update-delete-id-passing: 3/4] libtracker-data: Let delete_statement only accepts IDs for subject
- From: Philip Van Hoof <pvanhoof src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/sparql-update-delete-id-passing: 3/4] libtracker-data: Let delete_statement only accepts IDs for subject
- Date: Wed, 23 Mar 2011 15:40:17 +0000 (UTC)
commit ccbb1b9fa126e8889664a79da37ac482fd40c4df
Author: Philip Van Hoof <philip codeminded be>
Date: Wed Mar 23 15:30:28 2011 +0100
libtracker-data: Let delete_statement only accepts IDs for subject
src/libtracker-data/libtracker-data.vapi | 2 +-
src/libtracker-data/tracker-data-manager.c | 5 +++--
src/libtracker-data/tracker-data-update.c | 9 ++-------
src/libtracker-data/tracker-data-update.h | 3 +--
src/libtracker-data/tracker-sparql-query.vala | 22 +++++++++++++---------
5 files changed, 20 insertions(+), 21 deletions(-)
---
diff --git a/src/libtracker-data/libtracker-data.vapi b/src/libtracker-data/libtracker-data.vapi
index c2cd549..d3e5508 100644
--- a/src/libtracker-data/libtracker-data.vapi
+++ b/src/libtracker-data/libtracker-data.vapi
@@ -171,7 +171,7 @@ namespace Tracker {
public GLib.Variant update_sparql_blank (string update) throws Sparql.Error;
public void load_turtle_file (GLib.File file) throws Sparql.Error;
public void notify_transaction (bool start_timer);
- public void delete_statement (string? graph, string? subject, int s_id, string predicate, string object) throws Sparql.Error, DateError;
+ public void delete_statement (string? graph, int subject_id, string predicate, string object) throws Sparql.Error, DateError;
public void update_statement (string? graph, string subject, string predicate, string object) throws Sparql.Error, DateError;
public void insert_statement (string? graph, string subject, string predicate, string object) throws Sparql.Error, DateError;
public void insert_statement_with_uri (string? graph, string subject, string predicate, string object) throws Sparql.Error;
diff --git a/src/libtracker-data/tracker-data-manager.c b/src/libtracker-data/tracker-data-manager.c
index f59569c..e83bf02 100644
--- a/src/libtracker-data/tracker-data-manager.c
+++ b/src/libtracker-data/tracker-data-manager.c
@@ -432,7 +432,8 @@ update_property_value (const gchar *ontology_path,
}
if (!unsup_onto_err) {
- tracker_data_delete_statement (NULL, subject, 0, predicate, str, &error);
+ gint subject_id = tracker_data_query_resource_id (subject);
+ tracker_data_delete_statement (NULL, subject_id, predicate, str, &error);
if (!error)
tracker_data_update_buffer_flush (&error);
}
@@ -1285,7 +1286,7 @@ check_for_deleted_domain_index (TrackerClass *class)
tracker_property_del_domain_index (prop, class);
tracker_class_del_domain_index (class, prop);
- tracker_data_delete_statement (NULL, tracker_class_get_uri (class), 0,
+ tracker_data_delete_statement (NULL, tracker_class_get_id (class),
TRACKER_PREFIX "domainIndex",
tracker_property_get_uri (prop),
&error);
diff --git a/src/libtracker-data/tracker-data-update.c b/src/libtracker-data/tracker-data-update.c
index 3375972..fbcc086 100644
--- a/src/libtracker-data/tracker-data-update.c
+++ b/src/libtracker-data/tracker-data-update.c
@@ -2115,23 +2115,18 @@ resource_buffer_switch (const gchar *graph,
void
tracker_data_delete_statement (const gchar *graph,
- const gchar *subject,
- gint s_id,
+ gint subject_id,
const gchar *predicate,
const gchar *object,
GError **error)
{
TrackerClass *class;
- gint subject_id = 0;
gboolean change = FALSE;
- g_return_if_fail (s_id != 0 || subject != NULL);
g_return_if_fail (predicate != NULL);
g_return_if_fail (object != NULL);
g_return_if_fail (in_transaction);
- subject_id = (s_id != 0) ? s_id : query_resource_id (subject);
-
if (subject_id == 0) {
/* subject not in database */
return;
@@ -2225,7 +2220,7 @@ tracker_data_delete_statement (const gchar *graph,
TrackerStatementDelegate *delegate;
delegate = g_ptr_array_index (delete_callbacks, n);
- delegate->callback (graph_id, graph, subject_id, subject,
+ delegate->callback (graph_id, graph, subject_id, NULL,
pred_id, object_id,
object,
resource_buffer->types,
diff --git a/src/libtracker-data/tracker-data-update.h b/src/libtracker-data/tracker-data-update.h
index 77011e4..4489dcf 100644
--- a/src/libtracker-data/tracker-data-update.h
+++ b/src/libtracker-data/tracker-data-update.h
@@ -50,8 +50,7 @@ GQuark tracker_data_error_quark (void);
/* Metadata */
void tracker_data_delete_statement (const gchar *graph,
- const gchar *subject,
- gint s_id,
+ gint subject_id,
const gchar *predicate,
const gchar *object,
GError **error);
diff --git a/src/libtracker-data/tracker-sparql-query.vala b/src/libtracker-data/tracker-sparql-query.vala
index 82613f8..15d69d7 100644
--- a/src/libtracker-data/tracker-sparql-query.vala
+++ b/src/libtracker-data/tracker-sparql-query.vala
@@ -798,31 +798,35 @@ public class Tracker.Sparql.Query : Object {
int s_id = 0;
if (current () == SparqlTokenType.VAR) {
- string as_str;
-
next ();
- as_str = var_value_map.lookup (get_last_string ().substring (1));
+ result = var_value_map.lookup (get_last_string ().substring (1));
if (for_del_sub) {
- s_id = as_str.to_int ();
- result = null;
- } else {
- result = as_str;
+ s_id = result.to_int ();
}
-
} else if (current () == SparqlTokenType.IRI_REF) {
next ();
result = get_last_string (1);
+
+ if (for_del_sub) {
+ s_id = Data.query_resource_id (result);
+ }
} else if (current () == SparqlTokenType.PN_PREFIX) {
// prefixed name with namespace foo:bar
next ();
string ns = get_last_string ();
expect (SparqlTokenType.COLON);
result = resolve_prefixed_name (ns, get_last_string ().substring (1));
+ if (for_del_sub) {
+ s_id = Data.query_resource_id (result);
+ }
} else if (current () == SparqlTokenType.COLON) {
// prefixed name without namespace :bar
next ();
result = resolve_prefixed_name ("", get_last_string ().substring (1));
+ if (for_del_sub) {
+ s_id = Data.query_resource_id (result);
+ }
} else if (accept (SparqlTokenType.BLANK_NODE)) {
// _:foo
expect (SparqlTokenType.COLON);
@@ -962,7 +966,7 @@ public class Tracker.Sparql.Query : Object {
Data.update_statement (current_graph, current_subject, current_predicate, object);
} else if (delete_statements) {
// delete triple from database
- Data.delete_statement (current_graph, current_subject, current_subject_id, current_predicate, object);
+ Data.delete_statement (current_graph, current_subject_id, current_predicate, object);
} else {
// insert triple into database
Data.insert_statement (current_graph, current_subject, current_predicate, object);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]