[tracker/wip/carlosg/portal: 33/36] libtracker-data: Allow prefixed names in constraint rules



commit 91feceb02d87de4d579548fa860ad3ae3a0e01c1
Author: Carlos Garnacho <carlosg gnome org>
Date:   Sun Jul 5 19:26:38 2020 +0200

    libtracker-data: Allow prefixed names in constraint rules
    
    In addition to IRIREFs, this way one can CONSTRAINT GRAPH tracker:Audio
    without unrolling the full tracker: namespace.

 src/libtracker-data/tracker-sparql-grammar.h | 4 ++--
 src/libtracker-data/tracker-sparql.c         | 5 +++--
 2 files changed, 5 insertions(+), 4 deletions(-)
---
diff --git a/src/libtracker-data/tracker-sparql-grammar.h b/src/libtracker-data/tracker-sparql-grammar.h
index b659abde5..b26a32ea3 100644
--- a/src/libtracker-data/tracker-sparql-grammar.h
+++ b/src/libtracker-data/tracker-sparql-grammar.h
@@ -1509,12 +1509,12 @@ static const TrackerGrammarRule rule_SelectQuery[] = { R(SelectClause), GTE0(hel
  */
 static const TrackerGrammarRule rule_PrefixDecl[] = { L(PREFIX), T(PNAME_NS), T(IRIREF), NIL };
 
-/* ConstraintDecl ::= 'CONSTRAINT' ( 'GRAPH' | 'SERVICE' ) ( ( IRIREF | 'DEFAULT' | 'ALL' ) ( ',' ( IRIREF | 
'DEFAULT' | 'ALL' ) )* )?
+/* ConstraintDecl ::= 'CONSTRAINT' ( 'GRAPH' | 'SERVICE' ) ( ( PNAME_LN | IRIREF | 'DEFAULT' | 'ALL' ) ( ',' 
( PNAME_LN | IRIREF | 'DEFAULT' | 'ALL' ) )* )?
  *
  * TRACKER EXTENSION
  */
 static const TrackerGrammarRule helper_ConstraintDecl_or_1[] = { L(GRAPH), L(SERVICE), NIL };
-static const TrackerGrammarRule helper_ConstraintDecl_or_2[] = { T(IRIREF), L(DEFAULT), L(ALL), NIL };
+static const TrackerGrammarRule helper_ConstraintDecl_or_2[] = { T(PNAME_LN), T(IRIREF), L(DEFAULT), L(ALL), 
NIL };
 static const TrackerGrammarRule helper_ConstraintDecl_seq_1[] = { L(COMMA), OR(helper_ConstraintDecl_or_2), 
NIL };
 static const TrackerGrammarRule helper_ConstraintDecl_gte0_1[] = { S(helper_ConstraintDecl_seq_1), NIL };
 static const TrackerGrammarRule helper_ConstraintDecl_opt_1[] = { OR(helper_ConstraintDecl_or_2), 
GTE0(helper_ConstraintDecl_gte0_1), NIL };
diff --git a/src/libtracker-data/tracker-sparql.c b/src/libtracker-data/tracker-sparql.c
index a4940d025..f4e7e5b28 100644
--- a/src/libtracker-data/tracker-sparql.c
+++ b/src/libtracker-data/tracker-sparql.c
@@ -2835,7 +2835,7 @@ translate_ConstraintDecl (TrackerSparql  *sparql,
        gboolean graph = FALSE;
        gboolean filter_unnamed_graph = TRUE;
 
-       /* ConstraintDecl ::= 'CONSTRAINT' ( 'GRAPH' | 'SERVICE' ) ( ( IRIREF | 'DEFAULT' | 'ALL' ) ( ',' ( 
IRIREF | 'DEFAULT' | 'ALL' ) )* )?
+       /* ConstraintDecl ::= 'CONSTRAINT' ( 'GRAPH' | 'SERVICE' ) ( ( PNAME_LN | IRIREF | 'DEFAULT' | 'ALL' 
) ( ',' ( PNAME_LN | IRIREF | 'DEFAULT' | 'ALL' ) )* )?
         *
         * TRACKER EXTENSION
         */
@@ -2855,7 +2855,8 @@ translate_ConstraintDecl (TrackerSparql  *sparql,
        do {
                gchar *elem;
 
-               if (_accept (sparql, RULE_TYPE_TERMINAL, TERMINAL_TYPE_IRIREF)) {
+               if (_accept (sparql, RULE_TYPE_TERMINAL, TERMINAL_TYPE_IRIREF) ||
+                   _accept (sparql, RULE_TYPE_TERMINAL, TERMINAL_TYPE_PNAME_LN)) {
                        if (set) {
                                elem = _dup_last_string (sparql);
                                g_ptr_array_add (set, elem);


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