[tracker/wip/garnacho/sparql1.1: 5/23] libtracker-data: Add support for the SUBSTR() builtin function
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/wip/garnacho/sparql1.1: 5/23] libtracker-data: Add support for the SUBSTR() builtin function
- Date: Thu, 20 Aug 2015 08:53:06 +0000 (UTC)
commit d4869094aa0b1a76acc384ec7a7a352fe8b79abe
Author: Carlos Garnacho <carlosg gnome org>
Date: Tue Jul 28 20:29:39 2015 +0200
libtracker-data: Add support for the SUBSTR() builtin function
This function is defined in Sparql 1.1 query language recommedation,
http://www.w3.org/TR/sparql11-query/#func-substr
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 9b2dfbb..851917b 100644
--- a/src/libtracker-data/tracker-sparql-expression.vala
+++ b/src/libtracker-data/tracker-sparql-expression.vala
@@ -1230,6 +1230,12 @@ class Tracker.Sparql.Expression : Object {
type = translate_aggregate_expression (sql);
sql.append (")");
return type;
+ case SparqlTokenType.SUBSTR:
+ next ();
+ expect (SparqlTokenType.OPEN_PARENS);
+ var result = translate_function (sql, FN_NS + "substring");
+ expect (SparqlTokenType.CLOSE_PARENS);
+ return result;
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 a1454aa..903de58 100644
--- a/src/libtracker-data/tracker-sparql-scanner.vala
+++ b/src/libtracker-data/tracker-sparql-scanner.vala
@@ -321,6 +321,10 @@ public class Tracker.SparqlScanner : Object {
case 't':
if (matches (begin, "STRLEN")) return SparqlTokenType.STRLEN;
break;
+ case 'U':
+ case 'u':
+ if (matches (begin, "SUBSTR")) return SparqlTokenType.SUBSTR;
+ break;
}
break;
}
@@ -986,6 +990,7 @@ public enum Tracker.SparqlTokenType {
STRING_LITERAL_LONG1,
STRING_LITERAL_LONG2,
STRLEN,
+ SUBSTR,
SUM,
TRUE,
UCASE,
@@ -1087,6 +1092,7 @@ public enum Tracker.SparqlTokenType {
case STRING_LITERAL_LONG1: return "string literal";
case STRING_LITERAL_LONG2: return "string literal";
case STRLEN: return "`STRLEN'";
+ case SUBSTR: return "`SUBSTR'";
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]