[tracker/wip/carlosg/sparql1.1: 165/201] libtracker-data: Do not error out on unknown graphs
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/wip/carlosg/sparql1.1: 165/201] libtracker-data: Do not error out on unknown graphs
- Date: Mon, 9 Sep 2019 22:32:41 +0000 (UTC)
commit 8e6e371e25b098c7f6e1a9015bf1122de9f91214
Author: Carlos Garnacho <carlosg gnome org>
Date: Sun Jul 14 23:45:06 2019 +0200
libtracker-data: Do not error out on unknown graphs
Those should be an equivalent to an empty graph instead. In order to
have the query valid for future executions where the graph might
exist, use the unionGraph with a check for its graph column.
src/libtracker-data/tracker-sparql.c | 27 ++++++++++++++-------------
1 file changed, 14 insertions(+), 13 deletions(-)
---
diff --git a/src/libtracker-data/tracker-sparql.c b/src/libtracker-data/tracker-sparql.c
index 59d5d5ab5..fc10de6c7 100644
--- a/src/libtracker-data/tracker-sparql.c
+++ b/src/libtracker-data/tracker-sparql.c
@@ -1160,16 +1160,8 @@ _add_quad (TrackerSparql *sparql,
triple_context = TRACKER_TRIPLE_CONTEXT (sparql->current_state.context);
ontologies = tracker_data_manager_get_ontologies (sparql->data_manager);
- if (tracker_token_get_literal (graph)) {
+ if (tracker_token_get_literal (graph))
graph_db = tracker_token_get_idstring (graph);
- if (tracker_data_manager_find_graph (sparql->data_manager, graph_db) == 0) {
- g_set_error (error, TRACKER_SPARQL_ERROR,
- TRACKER_SPARQL_ERROR_UNKNOWN_GRAPH,
- "Unknown graph '%s'",
- tracker_token_get_idstring (graph));
- return FALSE;
- }
- }
if (tracker_token_get_literal (predicate)) {
gboolean share_table = TRUE;
@@ -1813,13 +1805,22 @@ _end_triples_block (TrackerSparql *sparql,
} else if (table->predicate_path) {
_append_string_printf (sparql, "\"%s\"", table->sql_db_tablename);
} else {
- if (table->graph) {
- _append_string_printf (sparql, "\"%s\".\"%s\"",
+ if (table->graph &&
+ tracker_data_manager_find_graph (sparql->data_manager, table->graph)) {
+ _append_string_printf (sparql, "\"%s\".\"%s\" ",
table->graph,
table->sql_db_tablename);
} else {
- _append_string_printf (sparql, "\"unionGraph_%s\" ",
- table->sql_db_tablename);
+ if (table->graph) {
+ _append_string_printf (sparql,
+ "(SELECT * FROM \"unionGraph_%s\" "
+ "WHERE graph = (SELECT ID FROM Resource WHERE
Uri = \"%s\")) ",
+ table->sql_db_tablename,
+ table->graph);
+ } else {
+ _append_string_printf (sparql, "\"unionGraph_%s\" ",
+ table->sql_db_tablename);
+ }
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]