mozilla / mentat

UNMAINTAINED A persistent, relational store inspired by Datomic and DataScript.
https://mozilla.github.io/mentat/
Apache License 2.0
1.65k stars 115 forks source link

Pull enhancements #668

Open rnewman opened 6 years ago

rnewman commented 6 years ago
ncalexan commented 6 years ago

Consider whether it's better to return TypedValue::Ref(12345) or {:db/id 12345} — the former is an advantage of our type system, and simplifies extraction of values, but the latter might be more regular when considering fetching more values, and is the way Datomic represents an entity in pull.

I personally see Datomic's representation as a facet of their execution model -- referentially transparent and generally lazy. Our execution model is so different that I'd only want the Datomic-like representation for consistency of extract results, as you say.

We could, of course, grow :db/id-ref or {:db/id} to disambiguate one case from the other.

rnewman commented 6 years ago

To provide an example, Datomic does this:

(pull ?x [:some/long :some/ref])

➡️

{:some/long 12345 
 :some/ref {:db/id 12345}}

I think we should do this:

{:some/long Binding::Scalar(TypedValue::Long(12345))
 :some/ref Binding::Scalar(TypedValue::Ref(12345))}

and if you want the map form, do this:

(pull ?x [:some/long {:some/ref [:db/id]}])
rnewman commented 6 years ago

Much of this was done in #694 and #682.