[tracker/tracker-0.16] Fix AS ?foo handling in FTS queries



commit 9f80a3e08519134ad6ba41d847ea55319757f4bd
Author: Carlos Garnacho <carlosg gnome org>
Date:   Mon Apr 8 15:43:20 2013 +0200

    Fix AS ?foo handling in FTS queries
    
    FTS queries implicitly add an "AS var" clause to the translated
    SQL select query so values can be matched with the outer query that
    accesses FTS tables, which resulted in doubly added AS clauses if
    it was specified explicitly in SPARQL too.
    
    So, make sure the clause is just added once.

 src/libtracker-data/tracker-sparql-expression.vala |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)
---
diff --git a/src/libtracker-data/tracker-sparql-expression.vala 
b/src/libtracker-data/tracker-sparql-expression.vala
index 5ea69fb..aa59b02 100644
--- a/src/libtracker-data/tracker-sparql-expression.vala
+++ b/src/libtracker-data/tracker-sparql-expression.vala
@@ -126,6 +126,7 @@ class Tracker.Sparql.Expression : Object {
        internal PropertyType translate_select_expression (StringBuilder sql, bool subquery, int 
variable_index) throws Sparql.Error {
                Variable variable = null;
                bool expect_close_parens = false;
+               bool as_handled = false;
 
                long begin = sql.len;
                var type = PropertyType.UNKNOWN;
@@ -180,6 +181,7 @@ class Tracker.Sparql.Expression : Object {
                                variable = context.get_variable (get_last_string ().substring (1));
                        }
                        sql.append_printf (" AS %s", variable.sql_expression);
+                       as_handled = true;
 
                        if (subquery) {
                                var binding = new VariableBinding ();
@@ -199,7 +201,10 @@ class Tracker.Sparql.Expression : Object {
 
                        if (fts_sql == null) {
                                pattern.fts_variables += variable.sql_expression;
-                               sql.append_printf (" AS %s", variable.sql_expression);
+
+                               if (as_handled == false) {
+                                       sql.append_printf (" AS %s", variable.sql_expression);
+                               }
                        } else {
                                pattern.fts_variables += fts_sql;
                                pattern.queries_fts_data = true;


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