[tracker] SPARQL: Add support for COALESCE



commit 8a1107b74acc14902d8f0ce337892fb7cc10193c
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 76f6b93..17cc349 100644
--- a/src/libtracker-data/tracker-sparql-expression.vala
+++ b/src/libtracker-data/tracker-sparql-expression.vala
@@ -1034,6 +1034,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]