[tracker/sparql-update: 4/25] libtracker-data: Use INSERT OR REPLACE instead of just REPLACE



commit 6845ebe19dad5a7b7a059e363da586904029b73a
Author: Philip Van Hoof <philip codeminded be>
Date:   Thu Mar 10 13:51:22 2011 +0100

    libtracker-data: Use INSERT OR REPLACE instead of just REPLACE

 src/libtracker-data/tracker-sparql-query.vala   |   14 ++++++--------
 src/libtracker-data/tracker-sparql-scanner.vala |    6 ++++++
 2 files changed, 12 insertions(+), 8 deletions(-)
---
diff --git a/src/libtracker-data/tracker-sparql-query.vala b/src/libtracker-data/tracker-sparql-query.vala
index f101dd8..6f1086a 100644
--- a/src/libtracker-data/tracker-sparql-query.vala
+++ b/src/libtracker-data/tracker-sparql-query.vala
@@ -449,7 +449,6 @@ public class Tracker.Sparql.Query : Object {
 			case SparqlTokenType.WITH:
 			case SparqlTokenType.INSERT:
 			case SparqlTokenType.DELETE:
-			case SparqlTokenType.REPLACE:
 				if (blank) {
 					ublank_nodes.open ((VariantType) "aa{ss}");
 					execute_insert_or_delete (ublank_nodes);
@@ -597,16 +596,15 @@ public class Tracker.Sparql.Query : Object {
 			update_statements = false;
 
 			// SILENT => ignore (non-syntax) errors
-			silent = accept (SparqlTokenType.SILENT);
 
-			if (current_graph == null && accept (SparqlTokenType.INTO)) {
-				parse_from_or_into_param ();
+			if (accept (SparqlTokenType.OR)) {
+				expect (SparqlTokenType.REPLACE);
+				update_statements = true;
 			}
-		} else if (accept (SparqlTokenType.REPLACE)) {
-			delete_statements = false;
-			update_statements = true;
 
-			/* REPLACE is currently not part of any SPARQL spec */
+			if (!update_statements) {
+				silent = accept (SparqlTokenType.SILENT);
+			}
 
 			if (current_graph == null && accept (SparqlTokenType.INTO)) {
 				parse_from_or_into_param ();
diff --git a/src/libtracker-data/tracker-sparql-scanner.vala b/src/libtracker-data/tracker-sparql-scanner.vala
index 7fde09e..9d3d595 100644
--- a/src/libtracker-data/tracker-sparql-scanner.vala
+++ b/src/libtracker-data/tracker-sparql-scanner.vala
@@ -72,6 +72,10 @@ public class Tracker.SparqlScanner : Object {
 					break;
 				}
 				break;
+			case 'O':
+			case 'o':
+				if (matches (begin, "OR")) return SparqlTokenType.OR;
+				break;
 			}
 			break;
 		case 3:
@@ -908,6 +912,7 @@ public enum Tracker.SparqlTokenType {
 	OPEN_BRACKET,
 	OPEN_PARENS,
 	OPTIONAL,
+	OR,
 	ORDER,
 	PLUS,
 	PN_PREFIX,
@@ -1001,6 +1006,7 @@ public enum Tracker.SparqlTokenType {
 		case OPEN_BRACKET: return "`['";
 		case OPEN_PARENS: return "`('";
 		case OPTIONAL: return "`OPTIONAL'";
+		case OR: return "`OR'";
 		case ORDER: return "`ORDER'";
 		case PLUS: return "`+'";
 		case PN_PREFIX: return "prefixed name";



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]