[tracker/string-functions: 2/2] Add fn:concat
- From: Mikael Ottela <mottela src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/string-functions: 2/2] Add fn:concat
- Date: Wed, 17 Feb 2010 17:17:58 +0000 (UTC)
commit 1c9a2d1cbb021c5ea464ee0ff92315982ddbda37
Author: Mikael Ottela <mikael ottela ixonos com>
Date: Wed Feb 17 02:55:43 2010 +0200
Add fn:concat
Add the implementation for the xpath function string-join and
unit-tests.
src/libtracker-data/tracker-sparql-query.vala | 11 +++++++++++
tests/libtracker-data/functions/Makefile.am | 4 +++-
.../functions/functions-xpath-4.out | 5 +++++
.../libtracker-data/functions/functions-xpath-4.rq | 7 +++++++
tests/libtracker-data/tracker-sparql-test.c | 2 +-
5 files changed, 27 insertions(+), 2 deletions(-)
---
diff --git a/src/libtracker-data/tracker-sparql-query.vala b/src/libtracker-data/tracker-sparql-query.vala
index 0b1f662..7cb1f01 100644
--- a/src/libtracker-data/tracker-sparql-query.vala
+++ b/src/libtracker-data/tracker-sparql-query.vala
@@ -1427,6 +1427,17 @@ public class Tracker.SparqlQuery : Object {
sql.append (")");
return PropertyType.BOOLEAN;
+ } else if (uri == FN_NS + "concat") {
+ translate_expression (sql);
+ sql.append ("||");
+ expect (SparqlTokenType.COMMA);
+ translate_expression (sql);
+ while (accept (SparqlTokenType.COMMA)) {
+ sql.append ("||");
+ translate_expression (sql);
+ }
+
+ return PropertyType.STRING;
} else if (uri == FN_NS + "string-join") {
sql.append ("SparqlStringJoin(");
expect (SparqlTokenType.OPEN_PARENS);
diff --git a/tests/libtracker-data/functions/Makefile.am b/tests/libtracker-data/functions/Makefile.am
index 377d20e..65abe3e 100644
--- a/tests/libtracker-data/functions/Makefile.am
+++ b/tests/libtracker-data/functions/Makefile.am
@@ -20,4 +20,6 @@ EXTRA_DIST = \
functions-xpath-2.out \
functions-xpath-2.rq \
functions-xpath-3.out \
- functions-xpath-3.rq
+ functions-xpath-3.rq \
+ functions-xpath-4.out \
+ functions-xpath-4.rq
diff --git a/tests/libtracker-data/functions/functions-xpath-4.out b/tests/libtracker-data/functions/functions-xpath-4.out
new file mode 100644
index 0000000..a0aa067
--- /dev/null
+++ b/tests/libtracker-data/functions/functions-xpath-4.out
@@ -0,0 +1,5 @@
+"fourth|testing"
+"fifth|purposes"
+"first|Test"
+"second|Text"
+"third|for"
diff --git a/tests/libtracker-data/functions/functions-xpath-4.rq b/tests/libtracker-data/functions/functions-xpath-4.rq
new file mode 100644
index 0000000..9338e90
--- /dev/null
+++ b/tests/libtracker-data/functions/functions-xpath-4.rq
@@ -0,0 +1,7 @@
+PREFIX ex: <http://example/>
+PREFIX ns: <http://www.w3.org/2005/xpath-functions#>
+
+SELECT fn:string-join((?s,?t),"|")
+{ ?_x ex:s ?s .
+ ?_x ex:t ?t .
+}
diff --git a/tests/libtracker-data/tracker-sparql-test.c b/tests/libtracker-data/tracker-sparql-test.c
index 659c19d..d53ccc4 100644
--- a/tests/libtracker-data/tracker-sparql-test.c
+++ b/tests/libtracker-data/tracker-sparql-test.c
@@ -70,10 +70,10 @@ const TestInfo tests[] = {
{ "functions/functions-xpath-1", "functions/data-1", FALSE },
{ "functions/functions-xpath-2", "functions/data-1", FALSE },
{ "functions/functions-xpath-3", "functions/data-1", FALSE },
+ { "functions/functions-xpath-4", "functions/data-1", FALSE },
{ "graph/graph-1", "graph/data-1", FALSE },
{ "graph/graph-2", "graph/data-2", FALSE },
{ "graph/graph-3", "graph/data-3", FALSE },
- { "functions/functions-xpath-3", "functions/data-1", FALSE },
{ "optional/q-opt-complex-1", "optional/complex-data-1", FALSE },
{ "regex/regex-query-001", "regex/regex-data-01", FALSE },
{ "regex/regex-query-002", "regex/regex-data-01", FALSE },
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]