Skip to content

docs: the "Ledger-Bound Mode" example (FROM <mydb:main> + GRAPH <g>) returns no rows #1975

Open

Description

@aaj3f

Not a big deal, but docs/query/datasets.md:612-630 ("SPARQL Execution Modes → Ledger-Bound Mode") says a query that targets a single ledger "via endpoint or single FROM clause" resolves GRAPH patterns against that ledger's named graphs. The example it gives is:

SELECT ?name ?price
FROM <mydb:main>
WHERE {
  GRAPH <http://example.org/graphs/products> { ?product ex:name ?name ; ex:price ?price . }
}

At main @ ac1e8a61b that shape returns no rows on every path Claude tried: the CLI (ledger view), POST /v1/fluree/query/{ledger}, and POST /v1/fluree/query. The same query without the FROM returns the rows on the ledger route and the CLI. Repro with a ledger b2x holding GRAPH <urn:ex:doc:1> { ex:ep1 ex:title "episode one" }:

POST /v1/fluree/query/b2x:main
  SELECT ?e ?t WHERE { GRAPH <urn:ex:doc:1> { ?e ex:title ?t } }                    → 1 row
  SELECT ?e ?t FROM <b2x:main> WHERE { GRAPH <urn:ex:doc:1> { ?e ex:title ?t } }     → bindings []   (no x-fdb-warning)
  SELECT ?e ?t FROM <b2x:main> FROM NAMED <urn:ex:doc:1> WHERE { GRAPH <urn:ex:doc:1> { … } }  → 1 row

As far as I can tell the engine is right and the doc is wrong. An explicit dataset clause with a FROM but no FROM NAMED has an empty named-graph set (SPARQL 1.1 §13.2), and that's exactly what build_within_ledger_dataset_from_ast (fluree-db-api/src/view/query.rs:1146-1194 at main @ 0c5d32c11) and ledger_scoped_sparql_dataset_spec (fluree-db-server/src/routes/query.rs:2573) build.

Minimally we could fix the example: drop the FROM, or add FROM NAMED <http://example.org/graphs/products>. We'd also drop "or single FROM clause" from the sentence above it. This is more of a suggestion than a must: the server already emits an x-fdb-warning for the mirror case, FROM NAMED without FROM (dataset_semantics_warning_headers, query.rs:2689-2712). A FROM without FROM NAMED whose WHERE uses GRAPH is just as silent, so it might be worth the same treatment.

The reason I'm raising it: one of our own downstream integrations injects FROM <ledger> into every single-ledger SPARQL query, and as a result it can't see any named graph (#1279's symptom, via a different route). I suspect this section is where the "that's harmless" assumption came from.

Possibly the same family as #1972, though a different shape: there a from carrying a #graph fragment is silently ignored on the CLI's single-ledger path, while here the engine is doing what the spec says and only the doc is off.

Activity

  1. added
    documentation
    P3
    area:sparql
    on Sep 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3area:sparqldocumentation

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions