[tracker/sparql-refactor: 6/16] SPARQL: Fix literal binding in subqueries



commit 5abd4496f31c3ebab5e061a32311cc60848518c3
Author: Jürg Billeter <j bitron ch>
Date:   Wed Mar 24 17:21:25 2010 +0100

    SPARQL: Fix literal binding in subqueries

 src/libtracker-data/tracker-sparql-query.vala |   14 ++++++++------
 1 files changed, 8 insertions(+), 6 deletions(-)
---
diff --git a/src/libtracker-data/tracker-sparql-query.vala b/src/libtracker-data/tracker-sparql-query.vala
index 227a1cf..f5b84d7 100644
--- a/src/libtracker-data/tracker-sparql-query.vala
+++ b/src/libtracker-data/tracker-sparql-query.vala
@@ -771,6 +771,7 @@ public class Tracker.SparqlQuery : Object {
 		var type = PropertyType.UNKNOWN;
 
 		var pattern_sql = new StringBuilder ();
+		var old_bindings = (owned) bindings;
 
 		sql.append ("SELECT ");
 
@@ -805,6 +806,9 @@ public class Tracker.SparqlQuery : Object {
 			}
 		}
 
+		var where_bindings = (owned) bindings;
+		bindings = (owned) old_bindings;
+
 		bool first = true;
 		if (accept (SparqlTokenType.STAR)) {
 			foreach (var variable in context.var_map.get_values ()) {
@@ -821,8 +825,6 @@ public class Tracker.SparqlQuery : Object {
 				}
 			}
 		} else {
-			var old_bindings = (owned) bindings;
-
 			while (true) {
 				if (!first) {
 					sql.append (", ");
@@ -847,11 +849,11 @@ public class Tracker.SparqlQuery : Object {
 				}
 				break;
 			}
+		}
 
-			// literals in select expressions need to be bound before literals in the where clause
-			foreach (var binding in old_bindings) {
-				bindings.append (binding);
-			}
+		// literals in select expressions need to be bound before literals in the where clause
+		foreach (var binding in where_bindings) {
+			bindings.append (binding);
 		}
 
 		// select from results of WHERE clause



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