[tracker/wip/carlosg/sparql-parser-ng: 2/6] libtracker-data: Support inverse property path



commit 1bb1668aef7ce352ef4609cf9bf8a9114ed45589
Author: Carlos Garnacho <carlosg gnome org>
Date:   Sat Nov 3 13:14:35 2018 +0100

    libtracker-data: Support inverse property path
    
    "?a ^:foo ?b" is equivalent to "?b :foo ?a", invert the subject/predicate
    in order to handle this.

 src/libtracker-data/tracker-sparql.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)
---
diff --git a/src/libtracker-data/tracker-sparql.c b/src/libtracker-data/tracker-sparql.c
index c085d6e1d..1961e6dad 100644
--- a/src/libtracker-data/tracker-sparql.c
+++ b/src/libtracker-data/tracker-sparql.c
@@ -4093,14 +4093,26 @@ static gboolean
 translate_PathEltOrInverse (TrackerSparql  *sparql,
                             GError        **error)
 {
+       TrackerToken old_object, old_subject, *old_token;
+
        /* PathEltOrInverse ::= PathElt | '^' PathElt
         */
+       old_object = sparql->current_state.object;
+       old_subject = sparql->current_state.subject;
+       old_token = sparql->current_state.token;
+
        if (_accept (sparql, RULE_TYPE_LITERAL, LITERAL_PATH_INVERSE)) {
-               _unimplemented ("Property paths");
+               sparql->current_state.object = old_subject;
+               sparql->current_state.subject = old_object;
+               sparql->current_state.token = &sparql->current_state.subject;
        }
 
        _call_rule (sparql, NAMED_RULE_PathElt, error);
 
+       sparql->current_state.subject = old_subject;
+       sparql->current_state.object = old_object;
+       sparql->current_state.token = old_token;
+
        return TRUE;
 }
 


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