Skip to content
This repository was archived by the owner on Sep 12, 2018. It is now read-only.
This repository was archived by the owner on Sep 12, 2018. It is now read-only.

[tx] Handle lookup-refs in transactor #183

@ncalexan

Description

@ncalexan

After #164, we parse lookup-refs; this ticket tracks rewriting lookup-refs in assertions. Assertions of the form

[[IDENT :db/ref-attr [:db/unique-attr VALUE]]]

are equivalent to finding the ENTID such that (ENTID :db/unique-attr VALUE) is an assertion, and then transacting [[IDENT :db/ref-attr ENTID]].

In the Clojure implementation, I collected all lookup-refs, wrote them all to a temporary table, and then handled them in a query. This is efficient when lookup up hundreds or thousands of lookup-refs, as happens when re-importing an already imported database. (In this case many lookup-refs match.) It's not efficient when we have only a handful of lookup-refs. A sophisticated implementation might have multiple regimes, sometimes using a temporary table and sometimes using a small bespoke query to do the lookups.

For the record, lookup-refs that don't resolve cause the Mentat transaction to fail (just like Datomic).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions