[tracker: 2/9] libtracker-data: Add support for RAND() builtin function
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker: 2/9] libtracker-data: Add support for RAND() builtin function
- Date: Wed, 2 Dec 2015 16:51:38 +0000 (UTC)
commit c0feb9555a800e5355903996e95af08e130993bc
Author: Carlos Garnacho <carlosg gnome org>
Date: Wed Jul 29 00:03:14 2015 +0200
libtracker-data: Add support for RAND() builtin function
This function is defined in Sparql 1.1 query language recommendation,
http://www.w3.org/TR/sparql11-query/#idp2130040
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 59c4964..247a066 100644
--- a/src/libtracker-data/tracker-sparql-expression.vala
+++ b/src/libtracker-data/tracker-sparql-expression.vala
@@ -1343,6 +1343,12 @@ class Tracker.Sparql.Expression : Object {
type = translate_aggregate_expression (sql);
sql.append (")");
return type;
+ case SparqlTokenType.RAND:
+ next ();
+ expect (SparqlTokenType.OPEN_PARENS);
+ expect (SparqlTokenType.CLOSE_PARENS);
+ sql.append ("SparqlRand()");
+ return PropertyType.DOUBLE;
case SparqlTokenType.SECONDS:
next ();
expect (SparqlTokenType.OPEN_PARENS);
diff --git a/src/libtracker-data/tracker-sparql-scanner.vala b/src/libtracker-data/tracker-sparql-scanner.vala
index a27b99b..2fbbcf6 100644
--- a/src/libtracker-data/tracker-sparql-scanner.vala
+++ b/src/libtracker-data/tracker-sparql-scanner.vala
@@ -189,6 +189,10 @@ public class Tracker.SparqlScanner : Object {
case 'n':
if (matches (begin, "NULL")) return SparqlTokenType.NULL;
break;
+ case 'R':
+ case 'r':
+ if (matches (begin, "RAND")) return SparqlTokenType.RAND;
+ break;
case 'S':
case 's':
if (matches (begin, "SHA1")) return SparqlTokenType.SHA1;
@@ -1088,6 +1092,7 @@ public enum Tracker.SparqlTokenType {
PLUS,
PN_PREFIX,
PREFIX,
+ RAND,
REDUCED,
REGEX,
REPLACE,
@@ -1209,6 +1214,7 @@ public enum Tracker.SparqlTokenType {
case PLUS: return "`+'";
case PN_PREFIX: return "prefixed name";
case PREFIX: return "`PREFIX'";
+ case RAND: return "`RAND'";
case REDUCED: return "`REDUCED'";
case REGEX: return "`REGEX'";
case REPLACE: return "`REPLACE'";
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]