gjhiggins/rdflib — Issue #85: SPARQL query with "OPTIONAL" triggers error in mysql backend
Author: gjhiggins
Created: 2011-10-19 01:16:20+00:00
State: open

Originally filed by cuu...@gmail.com on 2009-10-14T14:54:56

What steps will reproduce the problem?
1. Initialize mysql backend
2. Insert triple that has Literal as value
3. Execute SPARQL query "SELECT ?s ?p ?o WHERE { ?s ?p ?o . OPTIONAL { ?o
?op ?ov } }"

A python script that demonstrates this problem is attached.

What is the expected output? What do you see instead?

I would expect query to work and return some or no results.

Instead I get traceback that ends with:

/usr/local/lib/python2.6/dist-packages/rdflib-2.4.2-py2.6-linux-i686.egg/rdflib/store/MySQL.pyc
in determine_initial_subset(self, store)
216 if isinstance(self.subject, Literal):
217 raise ValueError(
--> 218 'A subject cannot be a literal.')
219
220 if isinstance(self.predicate, URIRef):

ValueError: A subject cannot be a literal.

What version of the product are you using? On what operating system?

rdflib 2.4.2, Ubuntu 9.04

Please provide any additional information below.

It seems that the error gets triggered by "OPTIONAL" keyword.