[tracker/wip/carlosg/sparql-corners: 11/12] libtracker-data: Handle nesting of multivalued property functions




commit b4cdb29f7a07fa73d03c5fb73319547058667225
Author: Carlos Garnacho <carlosg gnome org>
Date:   Sun Feb 28 19:56:42 2021 +0100

    libtracker-data: Handle nesting of multivalued property functions
    
    Do not convert results to string except in the topmost property function,
    so things like nmm:artistName(nmm:performer(?u)) work. This allows arbitrary
    nesting of single and multivalued properties to work consistently.
    
    Fixes: https://gitlab.gnome.org/GNOME/tracker/-/issues/259

 src/libtracker-data/tracker-sparql.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)
---
diff --git a/src/libtracker-data/tracker-sparql.c b/src/libtracker-data/tracker-sparql.c
index 10e04bfd1..c4aaaaaa9 100644
--- a/src/libtracker-data/tracker-sparql.c
+++ b/src/libtracker-data/tracker-sparql.c
@@ -150,6 +150,7 @@ typedef struct
        gint fts_match_idx;
 
        gboolean convert_to_string;
+       gboolean in_property_function;
 } TrackerSparqlState;
 
 struct _TrackerSparql
@@ -7595,8 +7596,13 @@ handle_property_function (TrackerSparql    *sparql,
                          GError          **error)
 {
        TrackerPropertyType type;
+       gboolean in_property_function;
 
-       if (tracker_property_get_multiple_values (property)) {
+       in_property_function = sparql->current_state->in_property_function;
+       sparql->current_state->in_property_function = TRUE;
+
+       if (!in_property_function &&
+           tracker_property_get_multiple_values (property)) {
                TrackerStringBuilder *str, *old;
 
                _append_string (sparql, "(SELECT GROUP_CONCAT (");
@@ -7638,12 +7644,13 @@ handle_property_function (TrackerSparql    *sparql,
                }
        }
 
-       _append_string (sparql, "WHERE ID = ");
+       _append_string (sparql, "WHERE ID IN (");
        _call_rule (sparql, NAMED_RULE_ArgList, error);
-       _append_string_printf (sparql, "AND \"%s\" IS NOT NULL",
+       _append_string_printf (sparql, ") AND \"%s\" IS NOT NULL",
                               tracker_property_get_name (property));
        _append_string (sparql, ") ");
 
+       sparql->current_state->in_property_function = in_property_function;
        sparql->current_state->expression_type = type;
 
        return TRUE;


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