[tracker/wip/carlosg/datetime-comparisons: 57/61] libtracker-data: Minor refactor




commit 5e0c448d5cbc74a120a6c6e635238b82d3116f9c
Author: Carlos Garnacho <carlosg gnome org>
Date:   Mon Apr 12 01:16:00 2021 +0200

    libtracker-data: Minor refactor
    
    Change the handling of relational expressions with 2 arguments (thus
    boolean), so it can accomodate other changes.

 src/libtracker-data/tracker-sparql.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)
---
diff --git a/src/libtracker-data/tracker-sparql.c b/src/libtracker-data/tracker-sparql.c
index a2eba01d6..522486b7b 100644
--- a/src/libtracker-data/tracker-sparql.c
+++ b/src/libtracker-data/tracker-sparql.c
@@ -7415,6 +7415,7 @@ translate_RelationalExpression (TrackerSparql  *sparql,
                                 GError        **error)
 {
        const gchar *old_sep;
+       gboolean bool_op = TRUE;
 
        /* RelationalExpression ::= NumericExpression ( '=' NumericExpression | '!=' NumericExpression | '<' 
NumericExpression | '>' NumericExpression | '<=' NumericExpression | '>=' NumericExpression | 'IN' 
ExpressionList | 'NOT' 'IN' ExpressionList )?
         */
@@ -7425,40 +7426,38 @@ translate_RelationalExpression (TrackerSparql  *sparql,
                old_sep = tracker_sparql_swap_current_expression_list_separator (sparql, ", ");
                _call_rule (sparql, NAMED_RULE_ExpressionList, error);
                tracker_sparql_swap_current_expression_list_separator (sparql, old_sep);
-               sparql->current_state->expression_type = TRACKER_PROPERTY_TYPE_BOOLEAN;
        } else if (_accept (sparql, RULE_TYPE_LITERAL, LITERAL_NOT)) {
                _expect (sparql, RULE_TYPE_LITERAL, LITERAL_OP_IN);
                _append_string (sparql, "NOT IN ");
                old_sep = tracker_sparql_swap_current_expression_list_separator (sparql, ", ");
                _call_rule (sparql, NAMED_RULE_ExpressionList, error);
                tracker_sparql_swap_current_expression_list_separator (sparql, old_sep);
-               sparql->current_state->expression_type = TRACKER_PROPERTY_TYPE_BOOLEAN;
        } else if (_accept (sparql, RULE_TYPE_LITERAL, LITERAL_OP_EQ)) {
                _append_string (sparql, " = ");
                _call_rule (sparql, NAMED_RULE_NumericExpression, error);
-               sparql->current_state->expression_type = TRACKER_PROPERTY_TYPE_BOOLEAN;
        } else if (_accept (sparql, RULE_TYPE_LITERAL, LITERAL_OP_NE)) {
                _append_string (sparql, " != ");
                _call_rule (sparql, NAMED_RULE_NumericExpression, error);
-               sparql->current_state->expression_type = TRACKER_PROPERTY_TYPE_BOOLEAN;
        } else if (_accept (sparql, RULE_TYPE_LITERAL, LITERAL_OP_LT)) {
                _append_string (sparql, " < ");
                _call_rule (sparql, NAMED_RULE_NumericExpression, error);
-               sparql->current_state->expression_type = TRACKER_PROPERTY_TYPE_BOOLEAN;
        } else if (_accept (sparql, RULE_TYPE_LITERAL, LITERAL_OP_GT)) {
                _append_string (sparql, " > ");
                _call_rule (sparql, NAMED_RULE_NumericExpression, error);
-               sparql->current_state->expression_type = TRACKER_PROPERTY_TYPE_BOOLEAN;
        } else if (_accept (sparql, RULE_TYPE_LITERAL, LITERAL_OP_LE)) {
                _append_string (sparql, " <= ");
                _call_rule (sparql, NAMED_RULE_NumericExpression, error);
-               sparql->current_state->expression_type = TRACKER_PROPERTY_TYPE_BOOLEAN;
        } else if (_accept (sparql, RULE_TYPE_LITERAL, LITERAL_OP_GE)) {
                _append_string (sparql, " >= ");
                _call_rule (sparql, NAMED_RULE_NumericExpression, error);
-               sparql->current_state->expression_type = TRACKER_PROPERTY_TYPE_BOOLEAN;
+       } else {
+               /* This is an unary expression */
+               bool_op = FALSE;
        }
 
+       if (bool_op)
+               sparql->current_state->expression_type = TRACKER_PROPERTY_TYPE_BOOLEAN;
+
        return TRUE;
 }
 


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