[tracker/wip/carlosg/sparql-fixes: 3/6] libtracker-data: Handle empty GroupGraphPattern




commit 50994b26771ea0c41cea0f2d8b2c2cab10dfcdc8
Author: Carlos Garnacho <carlosg gnome org>
Date:   Thu Aug 27 13:22:43 2020 +0200

    libtracker-data: Handle empty GroupGraphPattern
    
    If a GroupGraphPattern goes empty, we would maybe generate invalid
    SQL (e.g. "FROM ()") in union/minus/etc. As per
    https://www.w3.org/TR/sparql11-query/#emptyGroupPattern an empty
    group pattern should return one solution with no variables, so do
    precisely that.
    
    Fixes queries like e.g. "SELECT (1 AS ?a) { { } UNION { } }"

 src/libtracker-data/tracker-sparql.c | 2 ++
 1 file changed, 2 insertions(+)
---
diff --git a/src/libtracker-data/tracker-sparql.c b/src/libtracker-data/tracker-sparql.c
index 9eee56547..574df9f4e 100644
--- a/src/libtracker-data/tracker-sparql.c
+++ b/src/libtracker-data/tracker-sparql.c
@@ -5894,6 +5894,8 @@ translate_GroupGraphPattern (TrackerSparql  *sparql,
                _append_string (sparql, ") ");
        } else if (rule == NAMED_RULE_GroupGraphPatternSub) {
                _call_rule (sparql, rule, error);
+       } else {
+               _append_string (sparql, "SELECT NULL");
        }
 
        tracker_sparql_pop_context (sparql, TRUE);


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