fix: history @t/@op for IRI-valued objects + boolean @op#1203
Merged
Conversation
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.
This is based on #1198 branch and continues history query fixes
History queries on the
fix/history-rangesbranch only carried@t/@opmetadata onto literal-valued objects. Ref-valued predicates (
rdf:type,skos:inScheme,skosxl:prefLabel, etc.) were emitted with?vpopulatedbut
?tand?opnull. The root cause was structural:Binding::Sid(Sid)had no metadatachannel, so the
flakes_to_bindingsref arm and the{materialized,late_materialized}_object_bindinghelpers all droppedflake.t/flake.opwhenever the object was aFlakeValue::Ref.This PR fixes the asymmetry at the type layer rather than at individual
call sites, so the invariant "object bindings carry assertion metadata"
is uniform across the literal and ref paths. It also flips the on-the-wire
@oprepresentation from string ("assert"/"retract") to boolean(
true/false) to matchFlake.opon disk and avoid a per-row Arcallocation.
What changed
Binding type — metadata-capable struct variants
fluree-db-query/src/binding.rsBinding::Sidis nowSid { sid: Sid, t: Option<i64>, op: Option<bool> }.Binding::EncodedSidgains the samet/opOption fields.PartialEqandHash,matching the discipline already in place for
Binding::Lit. Setsemantics (joins, DISTINCT, GROUP BY, hash maps) ignore the metadata, so
a metadata-bearing object binding compares equal to a metadata-free one
with the same SID.
Binding::sid(sid)— no metadata (subjects, predicates, constants,VALUES rows, expression results).
Binding::sid_with_t(sid, t)— current-state object binding from aflake.
Binding::sid_with_t_op(sid, t, op)— history-mode object binding.Binding::encoded_sid(...)andBinding::encoded_sid_with_t_op(...)mirror these for the late-materialised path.
Binding::t() -> Option<i64>andBinding::op() -> Option<bool>cover all four metadata-bearing variants(
Lit,EncodedLit,Sid,EncodedSid).eval_t/eval_oproutethrough these so the variant list lives in exactly one place.
Object-construction sites threading
t/opObject positions only — subject and predicate bindings still emit
t: None, op: None, soT(?s)/OP(?p)keep the previous "no metadata"semantics rather than inventing a meaning.
binary_scan.rs::flakes_to_bindings— ref arm now usessid_with_t(...)for current-state scans (soT(?v)works forref-valued predicates outside history mode too) and
sid_with_t_op(...)in history mode.
object_binding.rs::{materialized_object_binding, late_materialized_object_binding}— accept an
op: Option<bool>parameter and propagate it to both theLitarm and theSid/EncodedSidarm.IriRefandBlankNodedecode kinds now carry
tlike the literal kinds do.binding.rs::from_object_with_t_op— fixed; this is the originallyreported zero-call-site constructor that motivated the bug write-up.
Both the literal and ref arms now thread
t/opthrough.OP()returns boolean (true/false)Flake.opis a boolean on disk. The previous string surface required aper-row
Arc::from("assert" | "retract")allocation in expressionevaluation and didn't reflect storage. Now:
eval_opreturnsComparableValue::Bool(op)."@op": "?var"— generatesBIND(op(?v) AS ?var)."@op": true/"@op": false— generatesFILTER(op(?v) = true|false)."assert","retract") are no longer accepted; theparser returns a clear error pointing users at the boolean form. (No
backward-compatibility shim — product is pre-release.)
fluree-db-query/src/expression/fluree.rs,fluree-db-query/src/parse/node_map.rs(new internalOpAnnotationenumwith
Variable(Arc<str>)/Constant(bool)variants).Parser:
@t/@oppermitted with@type: "@id"Removed the parser-level rejection that forbade
@t/@opannotations onexplicitly IRI-typed value objects. Now that ref-valued bindings carry the
metadata too, the parser-generated
BIND(t(?v) AS ?t)/BIND(op(?v) AS ?op)resolve correctly.Tests
fluree-db-api/tests/it_query_history_range.rs?opis nowboolin the flattened-row tuples, ordered asfalse < true).ex:knows:history_range_iri_object_sidecar_plus_base— verifies thesidecar+base path threads
t/opthrough the ref arm.history_range_iri_object_novelty_only— verifies the novelty branchof the history collector does too.
"@op": true/"@op": false.