[tracker] Added support for SPARQL ASK



commit 1e2f216719d81e53b80d02242a775f9259bab04a
Author: Philip Van Hoof <philip codeminded be>
Date:   Fri Jul 31 13:58:00 2009 +0200

    Added support for SPARQL ASK

 src/libtracker-data/tracker-sparql-query.vala |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)
---
diff --git a/src/libtracker-data/tracker-sparql-query.vala b/src/libtracker-data/tracker-sparql-query.vala
index 5f93bf7..94ba01f 100644
--- a/src/libtracker-data/tracker-sparql-query.vala
+++ b/src/libtracker-data/tracker-sparql-query.vala
@@ -305,6 +305,8 @@ public class Tracker.SparqlQuery : Object {
 		}
 	}
 
+	private bool is_ask { get; set; }
+
 	public DBResultSet? execute () throws Error {
 		var world = new Rasqal.World ();
 		world.open ();
@@ -339,7 +341,8 @@ public class Tracker.SparqlQuery : Object {
 			} else if (query.get_verb () == Rasqal.QueryVerb.DESCRIBE) {
 				throw new SparqlError.INTERNAL ("DESCRIBE is not supported");
 			} else if (query.get_verb () == Rasqal.QueryVerb.ASK) {
-				throw new SparqlError.INTERNAL ("ASK is not supported");
+				is_ask = true;
+				return execute_select (query);
 			} else {
 				throw new SparqlError.PARSE ("DELETE and INSERT are not supported in query mode");
 			}
@@ -434,6 +437,11 @@ public class Tracker.SparqlQuery : Object {
 		if (query.get_distinct ()) {
 			sql.append ("DISTINCT ");
 		}
+
+		if (is_ask) {
+			sql.append ("COUNT(1) > 0");
+		}
+
 		bool first = true;
 		for (int var_idx = 0; true; var_idx++) {
 			weak Rasqal.Variable variable = query.get_variable (var_idx);



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