Commits

Marc-Antoine Parent committed 2992506

remove a triple in all graphs has a different syntax

Comments (0)

Files changed (1)

virtuoso/vstore.py

         super(Virtuoso, self).add(statement, context, quoted)
 
     def remove(self, statement, context=None):
-        if statement == (None, None, None) and context is not None:
-            q = u'CLEAR GRAPH %s' % context.identifier.n3()
+        if statement == (None, None, None):
+            if context is not None:
+                q = u'CLEAR GRAPH %s' % context.identifier.n3()
+            else:
+                raise Exception("Clear all graphs???")
         else:
             query_bindings = _query_bindings(statement, context)
-            q = u'DELETE '
-            if context is not None:
-                q += u'FROM GRAPH %(G)s ' % query_bindings
-            q += u'{ %(S)s %(P)s %(O)s } WHERE { %(S)s %(P)s %(O)s }' % query_bindings
+            if context is None:
+                q = u'DELETE { GRAPH ?g { %(S)s %(P)s %(O)s }} WHERE { GRAPH ?g { %(S)s %(P)s %(O)s }}'
+            else:
+                q = u'DELETE FROM GRAPH %(G)s { %(S)s %(P)s %(O)s } WHERE { %(S)s %(P)s %(O)s }'
+            q = q % query_bindings
         self._query(q, commit=self._transaction is None)
         super(Virtuoso, self).remove(statement, context)
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.