Skip to content

rdflib 6.2.0 SPARQL parsing regression: multiple prefixes for same IRI not supported? #2077

Open
@jclerman

Description

@jclerman

I have a standard block of SPARQL prefixes that I use in some of my code, and I started getting test failures when I tried to update from rdflib 6.1.1 to rdflib 6.2.0. I noticed that the problem seems to be that somehow, support for multiple prefixes that resolve to the same URI seems to have been dropped.

Example block at the beginning of a SPARQL query:

PREFIX foo: <http://example.com#>
PREFIX bar: <http://example.com#>

The above should, as far as I know, be supported - but in rdflib 6.2.0, the foo: prefix will not be recognized when used in the query - and in fact, during parsing of the query, the foo: prefix is deleted.

The issue seems to be somewhere in rdfllib.namespace.__init__.py, in NamespaceManager.bind() - but I can't quite pin down what change is causing this new issue.

I do see this comment in the code, which was present in 6.1.1 but maybe it wasn't working as described?

        # Check if the bound_namespace contains a URI
        # and if so convert it into a URIRef for comparison
        # This is to prevent duplicate namespaces with the
        # same URI

however, if I correctly understand the intent behind that comment, it seems problematic - there is nothing wrong (as far as I know?) with multiple prefixes for the same URI in SPARQL.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions