[tracker] SPARQL: Report error when selecting undefined variables in updates



commit 57cd8e91e8ee5b447159cfdea906f9a3fe3f1823
Author: Jürg Billeter <j bitron ch>
Date:   Tue Aug 4 10:53:02 2009 +0200

    SPARQL: Report error when selecting undefined variables in updates

 src/libtracker-data/tracker-sparql-query.vala |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)
---
diff --git a/src/libtracker-data/tracker-sparql-query.vala b/src/libtracker-data/tracker-sparql-query.vala
index c209964..cb0801c 100644
--- a/src/libtracker-data/tracker-sparql-query.vala
+++ b/src/libtracker-data/tracker-sparql-query.vala
@@ -601,18 +601,30 @@ public class Tracker.SparqlQuery : Object {
 
 					if (triple.subject.type == Rasqal.Literal.Type.VARIABLE) {
 						subject = var_value_map.lookup (triple.subject.as_variable ().name);
+
+						if (subject == null) {
+							throw new SparqlError.PARSE ("Variable %s was selected but is unused in the query", triple.subject.as_variable ().name);
+						}
 					} else {
 						subject = get_string_from_literal (triple.subject);
 					}
 
 					if (triple.predicate.type == Rasqal.Literal.Type.VARIABLE) {
 						predicate = var_value_map.lookup (triple.predicate.as_variable ().name);
+
+						if (predicate == null) {
+							throw new SparqlError.PARSE ("Variable %s was selected but is unused in the query", triple.predicate.as_variable ().name);
+						}
 					} else {
 						predicate = get_string_from_literal (triple.predicate);
 					}
 
 					if (triple.object.type == Rasqal.Literal.Type.VARIABLE) {
 						object = var_value_map.lookup (triple.object.as_variable ().name);
+
+						if (object == null) {
+							throw new SparqlError.PARSE ("Variable %s was selected but is unused in the query", triple.object.as_variable ().name);
+						}
 					} else {
 						object = get_string_from_literal (triple.object);
 					}



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