Skip to content

Prepared queries ignore a literal :as-of, :valid-at or :any-valid-time #603

Closed

Description

@adityamukho

What happens

prepared::substitute takes query.as_of and query.valid_at out of the template before checking whether they are bind slots:

if let Some(AsOf::Slot(name)) = query.as_of.take() { ... }
if let Some(ValidAt::Slot(name)) = query.valid_at.take() { ... }

When the value is a literal (:as-of 1, :as-of "2024-01-01T00:00:00Z", :valid-at "...", :any-valid-time), the if let does not match and the value is dropped. Every PreparedQuery::execute and PreparedQuery::query then runs as if the query had no time travel: current transaction time, valid now.

db.execute("(transact [[:a :n 1]])")?;
db.execute("(transact [[:a :n 2]])")?;
let p = db.prepare("(query [:find ?v :as-of 1 :where [:a :n ?v]])")?;
p.execute(&[])?;   // 2 rows (both values); db.execute of the same query: 1 row

A prepared per-fact pseudo-attribute query with :any-valid-time fails with INT-026 for the same reason. Slot forms (:as-of $tx, :valid-at $t) work.

Since

0ef578e (2026-04-04, "use take/mem::replace instead of clone in substitution helpers"). On main (v2.x) and v3.

Fix

Only replace the field when it is a slot (if let Some(AsOf::Slot(name)) = &query.as_of), with regression tests for each literal form through execute and query. Fix on v3, backport to main.

Found while testing #594 (#602).

Activity

  1. added this to the v3.0.0 milestone on Oct 15, 2026
  2. added
    bugSomething isn't working
    known-issueBug present in a published release and not yet fixed in one; listed in the pinned known-issues issue
    on Oct 15, 2026
  3. adityamukho commented on Oct 15, 2026

    @adityamukho
    CollaboratorAuthor

    Fixed on v3 by #604 and on main by #605 (28f4a4e). Stays open until the next v2.x patch is released (data-integrity process, CONTRIBUTING.md).

  4. added a commit that references this issue on Oct 16, 2026
  5. adityamukho commented on Oct 16, 2026

    @adityamukho
    CollaboratorAuthor

    Fixed in v2.0.7 (released 2026-10-16; https://crates.io/crates/minigraf/2.0.7). Also fixed on v3.

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

    bugSomething isn't workingdata-integrityData integrity issueknown-issueBug present in a published release and not yet fixed in one; listed in the pinned known-issues issue

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions