Handle :db/ident and friends in cache application phase #193

Open
opened 2020-08-06 16:56:27 +00:00 by gburd · 0 comments
gburd commented 2020-08-06 16:56:27 +00:00 (Migrated from github.com)

Thanks to Schema, we know a bunch of things during algebrizing: a query like

[:find ?x :where [?x :db/ident :db/valueType]]

which currently translates to

SELECT DISTINCT `datoms00`.e AS `?x` FROM `datoms` AS `datoms00` WHERE `datoms00`.a = 1 AND `datoms00`.v = $v0
  Bindings:
    $v0 = Text(":db/valueType")

can instead be answered directly. So can

[:find ?valueType
 :in ?attr
 :where
 [?attr :db/valueType ?valueType]]

— that's also known via the schema without running SQL.

This makes it reasonable for dynamic callers to do most of their work through the query interface, rather than needing specialized access to Schema and the cache.

Thanks to `Schema`, we know a bunch of things during algebrizing: a query like ``` [:find ?x :where [?x :db/ident :db/valueType]] ``` which currently translates to ``` SELECT DISTINCT `datoms00`.e AS `?x` FROM `datoms` AS `datoms00` WHERE `datoms00`.a = 1 AND `datoms00`.v = $v0 Bindings: $v0 = Text(":db/valueType") ``` can instead be answered directly. So can ``` [:find ?valueType :in ?attr :where [?attr :db/valueType ?valueType]] ``` — that's also known via the schema without running SQL. This makes it reasonable for dynamic callers to do most of their work through the query interface, rather than needing specialized access to `Schema` and the cache.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: greg/mentat#193
No description provided.