diff --git a/CHANGELOG.md b/CHANGELOG.md index f6ea0f102..b28b7a6ad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Documentation +- Fix the Rust Quick Start (#884): register recursive rule clauses in separate `execute()` calls and define the keyword entity IDs used by prepared queries. Clarify the entity ID in the prepared-query error example. - Correct ordinary aggregate examples and lists (#777): v2 supports `count`, `count-distinct`, `sum`, `sum-distinct`, `min` and `max`; `avg` requires `:over`. Query behavior is unchanged. - Retire production-readiness tracker #383 in favor of the v3.0.0 milestone, preserving its release gates there. diff --git a/README.md b/README.md index 2a948b1c4..1e4e00438 100644 --- a/README.md +++ b/README.md @@ -94,12 +94,16 @@ tx.commit()?; // Time travel — query as of past transaction counter db.execute("(query [:find ?age :as-of 1 :where [:alice :person/age ?age]])")?; -// Recursive rule — transitive reachability -db.execute(r#"(rule [(reachable ?a ?b) [?a :friend ?b]]) - (rule [(reachable ?a ?b) [?a :friend ?m] (reachable ?m ?b)])"#)?; +// Recursive rule — register each clause with a separate execute() call +db.execute("(rule [(reachable ?a ?b) [?a :friend ?b]])")?; +db.execute("(rule [(reachable ?a ?b) [?a :friend ?m] (reachable ?m ?b)])")?; +db.execute("(query [:find ?friend :where (reachable :alice ?friend)])")?; // Prepared statement — parse + plan once, execute many times -use minigraf::BindValue; +use minigraf::{BindValue, EntityId}; +// Keywords map to UUIDv5 IDs in the OID namespace, including the leading colon. +let alice_id = EntityId::new_v5(&EntityId::NAMESPACE_OID, b":alice"); +let bob_id = EntityId::new_v5(&EntityId::NAMESPACE_OID, b":bob"); let pq = db.prepare("(query [:find ?name :as-of $tx :where [$entity :person/name ?name]])")?; let r1 = pq.execute(&[("tx", BindValue::TxCount(1)), ("entity", BindValue::Entity(alice_id))])?; let r2 = pq.execute(&[("tx", BindValue::TxCount(2)), ("entity", BindValue::Entity(bob_id))])?; diff --git a/docs/ERROR_REFERENCE.md b/docs/ERROR_REFERENCE.md index d0f5e3639..441e0ee6c 100644 --- a/docs/ERROR_REFERENCE.md +++ b/docs/ERROR_REFERENCE.md @@ -2282,6 +2282,7 @@ db.execute("(rule [(ancestor ?x ?y) [?x :parent ?y]])")?; - Prepare the query and supply a value for every slot: ```rust +let alice_id = minigraf::EntityId::new_v5(&minigraf::EntityId::NAMESPACE_OID, b":alice"); let pq = db.prepare("(query [:find ?status :as-of $tx :valid-at $date \ :where [$entity :employment/status ?status]])")?; let result = pq.execute(&[