[tracker/wip/carlosg/issue-56: 1/2] libtracker-data: Always set up blank node map on InsertClause



commit 2a2796ac0ef904670504e47d8dc413c4687e7368
Author: Carlos Garnacho <carlosg gnome org>
Date:   Tue Nov 13 22:47:27 2018 +0100

    libtracker-data: Always set up blank node map on InsertClause
    
    Commit c58f7aa419 late in wip/carlosg/sparql-parser-ng wrongly made this
    dependent on the query being an update_blank() one (i.e. we need to
    generate a GVariant with blank node results to give back). This actually
    defeated the path where we generate unique URNs for blank nodes on inserts,
    resulting in simple urns like <1> being generated.

 src/libtracker-data/tracker-sparql.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
---
diff --git a/src/libtracker-data/tracker-sparql.c b/src/libtracker-data/tracker-sparql.c
index faac603ad..3f1ead05f 100644
--- a/src/libtracker-data/tracker-sparql.c
+++ b/src/libtracker-data/tracker-sparql.c
@@ -2912,11 +2912,11 @@ translate_InsertClause (TrackerSparql  *sparql,
         */
        if (sparql->blank_nodes) {
                g_variant_builder_open (sparql->blank_nodes, G_VARIANT_TYPE ("a{ss}"));
-               sparql->current_state.blank_node_map =
-                       g_hash_table_new_full (g_str_hash, g_str_equal,
-                                              g_free, g_free);
        }
 
+       sparql->current_state.blank_node_map =
+               g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
+
        old_graph = sparql->current_state.graph;
 
        sparql->current_state.type = TRACKER_SPARQL_TYPE_INSERT;
@@ -6169,7 +6169,8 @@ translate_BlankNode (TrackerSparql  *sparql,
                                        bnode_id = tracker_data_query_unused_uuid (sparql->data_manager, 
iface);
                                        g_hash_table_insert (sparql->current_state.blank_node_map,
                                                             g_strdup (str), bnode_id);
-                                       g_variant_builder_add (sparql->blank_nodes, "{ss}", str, bnode_id);
+                                       if (sparql->blank_nodes)
+                                               g_variant_builder_add (sparql->blank_nodes, "{ss}", str, 
bnode_id);
                                }
 
                                tracker_token_literal_init (sparql->current_state.token, bnode_id);


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