RDFLib/rdflib — Issue #78: Sparql language comparison doesn't matc '' to None
Author: gjhiggins
Created: 2012-02-20 08:32:09+00:00
State: open

jus...@onebrightspace.com, 2009-09-01T09:44:13.000Z

What steps will reproduce the problem?
1. Add triple ?abc with no language
2. Sparql query: FILTER (lang(?abc) = '')

What is the expected output? What do you see instead?
Expected: Match
Actual: No Match

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

Please provide any additional information below.
All triples without a language have a defualt of None. I would expect an
empty quote to match a None language. So I can say:

FILTER (lang(?abc) = 'en-gb' || lang(?abc) = '')

Fix:

--- ./rdflib/sparql/sparqlOperators.py
+++ ./rdflib/sparql/sparqlOperators.py
@@ -313,7 +313,7 @@
if v == None: return ""
try :
val = bindings[v]
- if val == None:
+ if val == None or val.language == None:
return ""
else :
return val.language

Comment 1 by eik...@gmail.com

Comment 2 by eik...@gmail.com

Comment 3 by eik...@gmail.com
These issues involve bits that have been moved out of rdflib proper for now. We will re-open them
or move them to rdfextas as appropriate.