[tracker: 3/4] SPARQL: Add support for INSERT/DELETE DATA
- From: Jürg Billeter <juergbi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker: 3/4] SPARQL: Add support for INSERT/DELETE DATA
- Date: Wed, 22 Dec 2010 10:06:57 +0000 (UTC)
commit 6eef23448de86b797967f3d8c1351c968122d7fb
Author: Jürg Billeter <j bitron ch>
Date: Wed Dec 22 10:59:49 2010 +0100
SPARQL: Add support for INSERT/DELETE DATA
src/libtracker-data/tracker-sparql-query.vala | 28 +++++++++++++++++-----
src/libtracker-data/tracker-sparql-scanner.vala | 5 ++++
2 files changed, 26 insertions(+), 7 deletions(-)
---
diff --git a/src/libtracker-data/tracker-sparql-query.vala b/src/libtracker-data/tracker-sparql-query.vala
index 31f0663..e4be8b6 100644
--- a/src/libtracker-data/tracker-sparql-query.vala
+++ b/src/libtracker-data/tracker-sparql-query.vala
@@ -634,18 +634,30 @@ public class Tracker.Sparql.Query : Object {
}
}
+ // INSERT/DELETE DATA are simpler variants that don't support variables
+ bool data = (current_graph == null && accept (SparqlTokenType.DATA));
+
var pattern_sql = new StringBuilder ();
var sql = new StringBuilder ();
var template_location = get_location ();
- skip_braces ();
- if (accept (SparqlTokenType.WHERE)) {
- pattern.current_graph = current_graph;
- context = pattern.translate_group_graph_pattern (pattern_sql);
- pattern.current_graph = null;
+ if (!data) {
+ skip_braces ();
+
+ if (accept (SparqlTokenType.WHERE)) {
+ pattern.current_graph = current_graph;
+ context = pattern.translate_group_graph_pattern (pattern_sql);
+ pattern.current_graph = null;
+ } else {
+ context = new Context (this);
+
+ pattern_sql.append ("SELECT 1");
+ }
} else {
+ // WHERE pattern not supported for INSERT/DELETE DATA
+
context = new Context (this);
pattern_sql.append ("SELECT 1");
@@ -719,8 +731,10 @@ public class Tracker.Sparql.Query : Object {
} while (result_set.iter_next ());
}
- // reset location to the end of the update
- set_location (after_where);
+ if (!data) {
+ // reset location to the end of the update
+ set_location (after_where);
+ }
// ensure possible WHERE clause in next part gets the correct results
Data.update_buffer_flush ();
diff --git a/src/libtracker-data/tracker-sparql-scanner.vala b/src/libtracker-data/tracker-sparql-scanner.vala
index 61b4782..cff636f 100644
--- a/src/libtracker-data/tracker-sparql-scanner.vala
+++ b/src/libtracker-data/tracker-sparql-scanner.vala
@@ -130,6 +130,10 @@ public class Tracker.SparqlScanner : Object {
case 'D':
case 'd':
switch (begin[1]) {
+ case 'A':
+ case 'a':
+ if (matches (begin, "DATA")) return SparqlTokenType.DATA;
+ break;
case 'E':
case 'e':
if (matches (begin, "DESC")) return SparqlTokenType.DESC;
@@ -839,6 +843,7 @@ public enum Tracker.SparqlTokenType {
COMMA,
CONSTRUCT,
COUNT,
+ DATA,
DATATYPE,
DECIMAL,
DELETE,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]