[tracker] libtracker-data: Add support for the STRLEN() builtin function
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker] libtracker-data: Add support for the STRLEN() builtin function
- Date: Mon, 19 Oct 2015 12:14:59 +0000 (UTC)
commit 2df69e80588dad1a8d7fd53b2c1fa0ab903ffbba
Author: Carlos Garnacho <carlosg gnome org>
Date: Tue Jul 28 20:29:19 2015 +0200
libtracker-data: Add support for the STRLEN() builtin function
This function is defined in Sparql 1.1 query recommendation,
http://www.w3.org/TR/sparql11-query/#func-strlen
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 b655d0f..44dfe30 100644
--- a/src/libtracker-data/tracker-sparql-expression.vala
+++ b/src/libtracker-data/tracker-sparql-expression.vala
@@ -1224,6 +1224,12 @@ class Tracker.Sparql.Expression : Object {
var result = translate_function (sql, FN_NS + "upper-case");
expect (SparqlTokenType.CLOSE_PARENS);
return result;
+ case SparqlTokenType.STRLEN:
+ next ();
+ sql.append ("LENGTH(");
+ type = translate_aggregate_expression (sql);
+ sql.append (")");
+ return PropertyType.INTEGER;
case SparqlTokenType.REGEX:
translate_regex (sql);
query.no_cache = true;
diff --git a/src/libtracker-data/tracker-sparql-scanner.vala b/src/libtracker-data/tracker-sparql-scanner.vala
index ac2940c..a1454aa 100644
--- a/src/libtracker-data/tracker-sparql-scanner.vala
+++ b/src/libtracker-data/tracker-sparql-scanner.vala
@@ -317,6 +317,10 @@ public class Tracker.SparqlScanner : Object {
case 'i':
if (matches (begin, "SILENT")) return SparqlTokenType.SILENT;
break;
+ case 'T':
+ case 't':
+ if (matches (begin, "STRLEN")) return SparqlTokenType.STRLEN;
+ break;
}
break;
}
@@ -981,6 +985,7 @@ public enum Tracker.SparqlTokenType {
STRING_LITERAL2,
STRING_LITERAL_LONG1,
STRING_LITERAL_LONG2,
+ STRLEN,
SUM,
TRUE,
UCASE,
@@ -1081,6 +1086,7 @@ public enum Tracker.SparqlTokenType {
case STRING_LITERAL2: return "string literal";
case STRING_LITERAL_LONG1: return "string literal";
case STRING_LITERAL_LONG2: return "string literal";
+ case STRLEN: return "`STRLEN'";
case SUM: return "`SUM'";
case TRUE: return "`true'";
case UCASE: return "`UCASE'";
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]