fix(sparql): CONSTRUCT WHERE and STRBEFORE/STRAFTER edge cases#1380
Open
bplatz wants to merge 2 commits into
Open
fix(sparql): CONSTRUCT WHERE and STRBEFORE/STRAFTER edge cases#1380bplatz wants to merge 2 commits into
bplatz wants to merge 2 commits into
Conversation
Expand compact IRIs against @context in the testsuite's CONSTRUCT graph comparison (cw01/02/03). The engine emits valid compact JSON-LD (e.g. @id ":s1" with @context {"":"http://example.org/"}); the harness previously read @id and predicate keys literally, ignoring @context. Adds a minimal context expander handling prefix terms (including the empty prefix), @vocab, and @base. Tighten the CONSTRUCT WHERE shorthand to a triples-only block per the SPARQL 1.1 grammar, rejecting FILTER/GRAPH/OPTIONAL/etc. in that position (cw05/06).
Implement SPARQL 1.1 §17.4.3.7/8 semantics: a not-found search returns a plain empty literal (dropping arg1's language tag), a found match (including the empty search string) preserves arg1's tag, and an arg2 whose language tag is incompatible with arg1 raises a type error. Fixes W3C strbefore01a/02 and strafter01a/02. Preserve language tags on literal constants in expression position by lowering "x"@lang to STRLANG("x", "lang") instead of a bare string constant, so argument-compatibility checks can see the tag.
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.
A couple of narrow SPARQL correctness fixes surfaced by the W3C 1.1 query test suite. These are edge-case bugs in already-supported features — not gaps in functionality.
CONSTRUCT
@id: ":s1"with@context: {"": "http://example.org/"}). The W3C harness's graph comparator was reading@id/predicate keys literally and ignoring@context, so equivalent graphs compared unequal. Added a minimal context expander (prefix terms incl. the empty prefix,@vocab,@base). Engine output unchanged.CONSTRUCT WHEREshorthand was too permissive. Per the SPARQL 1.1 grammar the shorthand block is triples-only; we were routing it through the full group-graph-pattern parser and acceptingFILTER/GRAPH/etc. Now rejected as a syntax error, matching the spec's negative tests.STRBEFORE / STRAFTER
"x"@langbecame a bare"x"). They now lower toSTRLANG("x", "lang")so the tag survives — needed for the compatibility checks above, and correct for language-aware expressions generally.Validation
fluree-db-sparql,fluree-db-query, andfluree-db-apitest suites pass; added unit tests covering the STRBEFORE/STRAFTER cases and the CONSTRUCT context expansion.cargo fmt+clippyclean on the touched crates.