Repository navigation
fix: support solution modifiers in short form CONSTRUCT WHERE queries - #3660
Open
Thanatos9404 wants to merge 1 commit into
Open
Thanatos9404 wants to merge 1 commit into
Thanatos9404 wants to merge 1 commit into
Conversation
The template of a CONSTRUCT WHERE query was read at evaluation time from query.p.p, which is its basic graph pattern only when no LIMIT, OFFSET, ORDER BY or VALUES wraps the pattern. Build the template from the WHERE clause's triples in translateQuery instead, and give an empty CONSTRUCT template an empty template rather than treating it as the short form. Fixes RDFLib#1785
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary of changes
Fixes #1785.
A short form CONSTRUCT WHERE query with a solution modifier failed with
TypeError: 'NoneType' object is not iterable:translateQuerystored no template for the short form.evalConstructQuerythen read it fromquery.p.p.triples, which is the basic graph pattern only when the Project sits directly on it:As suggested in the issue, the fix is now upstream of evaluation:
translateQuerybuilds the template from the triples of the short form's WHERE clause, theFakeGroupGraphPattenthe parser creates for this step.evalConstructQueryusesquery.templateas it is, so the shape of the algebra no longer matters.Behaviour change:
CONSTRUCT { } WHERE { ... }now returns an empty graph, as an empty template builds no triples. Before, an empty template was treated as the short form. With a plain basic graph pattern and no modifiers, it returned the matched triples. Otherwise it raised the same TypeError, unless the query had no solutions.Checklist
the same change.
so maintainers can fix minor issues and keep your PR up to date.
The new
test/test_sparql/test_construct_where.pycovers:All but the unmodified short form fail on
main.These all pass:
test/test_sparql;ruff check,ruff format --checkand mypy;uv lock --check.