[tracker/wip/fts4: 17/21] libtracker-data: Fix fts detection when constructing SQL
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/wip/fts4: 17/21] libtracker-data: Fix fts detection when constructing SQL
- Date: Mon, 28 Jan 2013 10:03:36 +0000 (UTC)
commit bdc1f5aa1e47545417ce02c3d44d2a9ec9e71f68
Author: Carlos Garnacho <carlos lanedo com>
Date: Wed Dec 14 12:46:38 2011 +0100
libtracker-data: Fix fts detection when constructing SQL
It would previously miss the FTS binding, depending on the order
of the clauses. so something like { ?u fts:match 'foo'; a nie:DataObject }
would return results whereas { ?u a nie:DataObject ; fts:match 'foo' }
didn't.
src/libtracker-data/tracker-sparql-pattern.vala | 12 ++++--------
1 files changed, 4 insertions(+), 8 deletions(-)
---
diff --git a/src/libtracker-data/tracker-sparql-pattern.vala b/src/libtracker-data/tracker-sparql-pattern.vala
index 93dc166..ded3e9a 100644
--- a/src/libtracker-data/tracker-sparql-pattern.vala
+++ b/src/libtracker-data/tracker-sparql-pattern.vala
@@ -241,7 +241,6 @@ class Tracker.Sparql.Pattern : Object {
internal SelectContext translate_select (StringBuilder sql, bool subquery = false, bool scalar_subquery = false) throws Sparql.Error {
SelectContext result;
- bool has_fts_match = false;
if (scalar_subquery) {
result = new SelectContext.subquery (query, context);
@@ -254,8 +253,6 @@ class Tracker.Sparql.Pattern : Object {
var pattern_sql = new StringBuilder ();
var old_bindings = (owned) query.bindings;
- match_str = new StringBuilder ();
-
sql.append ("SELECT ");
expect (SparqlTokenType.SELECT);
@@ -289,8 +286,6 @@ class Tracker.Sparql.Pattern : Object {
foreach (var variable in context.var_set.get_keys ()) {
if (variable.binding == null) {
throw get_error ("use of undefined variable `%s'".printf (variable.name));
- } else if (variable.binding.table.sql_db_tablename == "fts") {
- has_fts_match = true;
}
}
@@ -354,7 +349,7 @@ class Tracker.Sparql.Pattern : Object {
// select from results of WHERE clause
- if (has_fts_match) {
+ if (match_str != null) {
sql.append (" FROM fts JOIN (");
sql.append (pattern_sql.str);
@@ -448,7 +443,7 @@ class Tracker.Sparql.Pattern : Object {
query.bindings.append (binding);
}
- if (has_fts_match) {
+ if (match_str != null) {
sql.append (") AS ranks USING (docid)");
sql.append_printf (" WHERE fts %s", match_str.str);
}
@@ -755,7 +750,8 @@ class Tracker.Sparql.Pattern : Object {
string escaped_literal = string.joinv ("''", binding.literal.split ("'"));
sql.append_printf (" MATCH '%s'", escaped_literal);
- if (match_str != null) {
+ if (match_str == null) {
+ match_str = new StringBuilder ();
match_str.append_printf (" MATCH '%s'", escaped_literal);
}
} else {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]