gjhiggins/rdfextras — Issue #9: SPARQL parsing problem with negative values
Author: gjhiggins
Created: 2011-10-19 02:59:02+00:00
State: open

Originally filed by gjhigg...@gmail.com on 2010-09-14T22:40:07

Issue 93 migrated from rdflib.

I am having problems with the following code, obtained from test_not_equals.py

(updated for rdfextras)

from rdflib import Namespace
from rdflib import plugin,RDF,RDFS,URIRef, Literal
from rdflib.parser import StringInputSource
from rdflib.graph import Graph,ReadOnlyGraphAggregate,ConjunctiveGraph
import rdflib
import sys
rdflib.plugin.register('sparql', rdflib.query.Processor,
'rdfextras.sparql.processor', 'Processor')
rdflib.plugin.register('sparql', rdflib.query.Result,
'rdfextras.sparql.query', 'SPARQLQueryResult')

def testSPARQLNotEquals():
NS = u"http://example.org/"
graph = ConjunctiveGraph()
graph.parse(StringInputSource("""
@prefix : .
@prefix rdf: <%s> .
:foo rdf:value 1.
:bar rdf:value -2."""%RDF), format="n3")
rt = graph.query("""SELECT ?node
WHERE {
?node rdf:value ?val .
FILTER (?val < -1) }
""",
initNs={'rdf':RDF },
DEBUG=True)
for row in rt:
print row
assert row == "http://example.org/bar"

testSPARQLNotEquals()

TypeError: bad operand type for unary -: 'Literal'
function createSPARQLPConstraint in evaluate.py at line 396
return eval(rt)

(val < (- 1))
sparql-p operator(s): operators.lt("?val",-(rdflib.term.Literal(u'1', datatype=rdflib.term.URIRef('http://www.w3.org/2001/XMLSchema#integer'))))