gjhiggins/rdflib — Issue #82: Sparql language comparison doesn't matc '' to None
Author: gjhiggins
Created: 2011-10-19 01:14:59+00:00
State: open

Originally filed by jus...@onebrightspace.com on 2009-09-01T09:44:13

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