RDFLib/rdflibissueplayground — Issue #9: SPARQL parsing problem with negative values
Author: gjhiggins
Created: 2012-02-20 07:43:27+00:00
State: open

gjhigg...@gmail.com, 2010-09-14T22:40:07.000Z

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'))))

Comment 1 by gjhigg...@gmail.com
Issue 30 has been merged into this issue.

Comment 2 by gjhigg...@gmail.com
Marked SPARQLNotEqualsNegative as "known_issue = True", thus disabling the test for both sparql and sparql2sql implementations.