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



commit 38095953e87b870edad0650ee12cbd4ff5ade61a
Author: JÃrg Billeter <j bitron ch>
Date:   Wed Jul 13 14:16:21 2011 +0200

    SPARQL: Add support for HAVING

 src/libtracker-data/tracker-sparql-pattern.vala |    7 ++++++-
 src/libtracker-data/tracker-sparql-scanner.vala |    6 ++++++
 2 files changed, 12 insertions(+), 1 deletions(-)
---
diff --git a/src/libtracker-data/tracker-sparql-pattern.vala b/src/libtracker-data/tracker-sparql-pattern.vala
index d2fb265..8e5bba3 100644
--- a/src/libtracker-data/tracker-sparql-pattern.vala
+++ b/src/libtracker-data/tracker-sparql-pattern.vala
@@ -362,7 +362,12 @@ class Tracker.Sparql.Pattern : Object {
 					sql.append (", ");
 				}
 				expression.translate_expression (sql);
-			} while (current () != SparqlTokenType.ORDER && current () != SparqlTokenType.LIMIT && current () != SparqlTokenType.OFFSET && current () != SparqlTokenType.CLOSE_BRACE && current () != SparqlTokenType.CLOSE_PARENS && current () != SparqlTokenType.EOF);
+			} while (current () != SparqlTokenType.HAVING && current () != SparqlTokenType.ORDER && current () != SparqlTokenType.LIMIT && current () != SparqlTokenType.OFFSET && current () != SparqlTokenType.CLOSE_BRACE && current () != SparqlTokenType.CLOSE_PARENS && current () != SparqlTokenType.EOF);
+
+			if (accept (SparqlTokenType.HAVING)) {
+				sql.append (" HAVING ");
+				expression.translate_constraint (sql);
+			}
 		}
 
 		if (accept (SparqlTokenType.ORDER)) {
diff --git a/src/libtracker-data/tracker-sparql-scanner.vala b/src/libtracker-data/tracker-sparql-scanner.vala
index 9d3d595..8f15d01 100644
--- a/src/libtracker-data/tracker-sparql-scanner.vala
+++ b/src/libtracker-data/tracker-sparql-scanner.vala
@@ -264,6 +264,10 @@ public class Tracker.SparqlScanner : Object {
 			case 'f':
 				if (matches (begin, "FILTER")) return SparqlTokenType.FILTER;
 				break;
+			case 'H':
+			case 'h':
+				if (matches (begin, "HAVING")) return SparqlTokenType.HAVING;
+				break;
 			case 'I':
 			case 'i':
 				if (matches (begin, "INSERT")) return SparqlTokenType.INSERT;
@@ -880,6 +884,7 @@ public enum Tracker.SparqlTokenType {
 	GRAPH,
 	GROUP,
 	GROUP_CONCAT,
+	HAVING,
 	IF,
 	INSERT,
 	INTEGER,
@@ -974,6 +979,7 @@ public enum Tracker.SparqlTokenType {
 		case GRAPH: return "`GRAPH'";
 		case GROUP: return "`GROUP'";
 		case GROUP_CONCAT: return "`GROUP_CONCAT'";
+		case HAVING: return "`HAVING'";
 		case IF: return "`IF'";
 		case INSERT: return "`INSERT'";
 		case INTEGER: return "`INTEGER'";



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