Skip to content

JSON-LD value-to-term rules are implemented separately in each reader #2407

Open

Description

@bplatz

Problem

A JSON-LD value becomes an RDF term in three separate places:

  • the transaction parser: parse_literal_value_with_meta in fluree-db-transact/src/parse/jsonld.rs
  • the adapter behind a bulk import, rdf::parse and inline shapes: process_literal in fluree-graph-json-ld/src/adapter.rs
  • the JSON-LD where parser: parse_value_object, value_object_dtc and parse_object_value in fluree-db-query/src/parse/node_map.rs

Each rule about how a context term or a value object types a value has to be written into each of them. When one is missed, a where pattern written like the insert no longer matches what the insert stored, or two readers store the same document differently.

Six changes have had to edit the where side by hand to match the write side:

The two write-side readers drift apart as well. In #2393, an array @value with no @json or @vector type was refused by a transaction but silently dropped by the adapter, until the expander refused it for both.

Proposal

One function that turns a JSON-LD value under its term definition into a term, called by all three readers, so the next rule is a one-place change.

The where side has intentional differences, and the shared function needs to keep them (see docs/reference/compatibility.md):

  • A variable ("?v" or {"@value": "?v"}) keeps its term's datatype as a constraint.
  • A map stays a node pattern under an @index term.
  • A pattern on a term defined as null is refused.

Target next: three of the rules above (6e4d006, 14695d2, #2393) exist only there.

Raised in review of #2393.

Activity

  1. added
    enhancement
    P3
    area:query
    on Nov 15, 2026
  2. bplatz commented on Nov 20, 2026

    @bplatz
    ContributorAuthor

    Folding in #2033, which asks for the same shared term parser from the read side. Together, the readers that turn a JSON-LD value into a term are:

    • the transaction parser: parse_literal_value_with_meta (fluree-db-transact/src/parse/jsonld.rs)
    • the adapter behind bulk import, rdf::parse and inline shapes: process_literal (fluree-graph-json-ld/src/adapter.rs)
    • the JSON-LD where parser: parse_value_object, value_object_dtc and parse_object_value (fluree-db-query/src/parse/node_map.rs)
    • the JSON-LD values clause: parse_values_cell (fluree-db-query/src/parse/values.rs)
    • SPARQL parameters: Value::parse (fluree-db-sparql/src/params.rs)

    From #2033: differences that are deliberate, such as null as UNDEF in values but refused as a parameter, stay with the caller. #2356, #2357 and #2360 are each one more rule that would otherwise need writing into several of these.

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:queryenhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions