RDFLib / rdflib-sqlalchemy

RDFLib store using SQLAlchemy dbapi as back-end
Other
148 stars 34 forks source link

Failure when trying to search for a triple where object is a Literal with a language tag #87

Closed anatoly-scherbakov closed 2 years ago

anatoly-scherbakov commented 2 years ago

UPD. I had to update the code, description, and title of the issue because I could reproduce it in an easier way.

Problem. Code and output: https://gist.github.com/anatoly-scherbakov/e7baee765ca9f22f419a2eb5a89689e8

The t in graph code will fail if the object of the triple t is a Literal with language tag defined. For example, in the code snippet provided above,

(
    URIRef('https://foo'),
    RDFS.comment,
    Literal('', lang='en'),
) in graph

throws an AttributeError: objLanguage on an empty graph.

I could try helping fix this but I need a better understanding of reasons of the error. I am not clear enough about how the table structure works.

mwatts15 commented 2 years ago

Thanks, @anatoly-scherbakov . The problem was that the code for deciding which tables to query (sloppily) checked for not obj rather than obj is None, but not Literal('', lang='en') == True.