[tracker/tracker-0.10] SPARQL: Add support for COALESCE



commit d984553cc267b785ec7599fa69935070e331f2d6
Author: JÃrg Billeter <j bitron ch>
Date:   Wed Jul 20 17:49:26 2011 +0200

    SPARQL: Add support for COALESCE
    
    Implemented as an alias to tracker:coalesce.

 src/libtracker-data/tracker-sparql-expression.vala |    6 ++++++
 src/libtracker-data/tracker-sparql-scanner.vala    |    6 ++++++
 2 files changed, 12 insertions(+), 0 deletions(-)
---
diff --git a/src/libtracker-data/tracker-sparql-expression.vala b/src/libtracker-data/tracker-sparql-expression.vala
index 1f39719..1205adb 100644
--- a/src/libtracker-data/tracker-sparql-expression.vala
+++ b/src/libtracker-data/tracker-sparql-expression.vala
@@ -1040,6 +1040,12 @@ class Tracker.Sparql.Expression : Object {
 		case SparqlTokenType.BOUND:
 			translate_bound_call (sql);
 			return PropertyType.BOOLEAN;
+		case SparqlTokenType.COALESCE:
+			next ();
+			expect (SparqlTokenType.OPEN_PARENS);
+			var result = translate_function (sql, TRACKER_NS + "coalesce");
+			expect (SparqlTokenType.CLOSE_PARENS);
+			return result;
 		case SparqlTokenType.IF:
 			return translate_if_call (sql);
 		case SparqlTokenType.SAMETERM:
diff --git a/src/libtracker-data/tracker-sparql-scanner.vala b/src/libtracker-data/tracker-sparql-scanner.vala
index 8f15d01..dda1343 100644
--- a/src/libtracker-data/tracker-sparql-scanner.vala
+++ b/src/libtracker-data/tracker-sparql-scanner.vala
@@ -318,6 +318,10 @@ public class Tracker.SparqlScanner : Object {
 			break;
 		case 8:
 			switch (begin[0]) {
+			case 'C':
+			case 'c':
+				if (matches (begin, "COALESCE")) return SparqlTokenType.COALESCE;
+				break;
 			case 'D':
 			case 'd':
 				switch (begin[1]) {
@@ -860,6 +864,7 @@ public enum Tracker.SparqlTokenType {
 	CLOSE_BRACE,
 	CLOSE_BRACKET,
 	CLOSE_PARENS,
+	COALESCE,
 	COLON,
 	COMMA,
 	CONSTRUCT,
@@ -958,6 +963,7 @@ public enum Tracker.SparqlTokenType {
 		case CLOSE_BRACE: return "`}'";
 		case CLOSE_BRACKET: return "`]'";
 		case CLOSE_PARENS: return "`)'";
+		case COALESCE: return "`COALESCE'";
 		case COLON: return "`:'";
 		case COMMA: return "`,'";
 		case CONSTRUCT: return "`CONSTRUCT'";



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