Fork me on GitHub
#asami
<
2020-08-05
>
quoll03:08:48

Asami 1.1.0 is now out. This has minor updates: • Entity arrays are now returned as vectors and not lists. • Entities now represent multi-arity attributes as a set of values. If more than one of an attribute is found, then a set of those values is returned in the entity. Similarly, providing a set will result in using the attribute multiple times in the graph. • Arrays in entities can be appended to by using the + annotation on attributes (see https://github.com/threatgrid/asami/wiki/Transactions#append-annotation for details) • Queries now accept _ symbols as wildcards, and accept shortened constraints (not just triples)

jjttjj17:08:37

It's mentioned in the docs that :db/ident can be any data type, but I'm not having luck getting it to work with vectors as idents. Is it actually any scalar data type?

quoll17:08:20

Yes. Though for the in-memory indices I’m surprised that it’s not working

jjttjj17:08:22

(def tx (d/transact conn {:tx-data [{:db/ident ["liz" 5] :name "Elizabeth"}]}))

(d/q '[:find [?n ...]
       :where [?p :name ?n] [?p :db/ident ["liz" 5]]] (d/db conn))

(d/entity (d/db conn) ["liz" 5])

(d/q '[:find ?p
       :where [?p :name ?n] [?p :db/ident ["liz" 5]]] (d/db conn))
yeah the 3 queries here and entity call return nil

quoll17:08:53

Oh, of course! It deconstructed it into a list!

quoll17:08:07

I could make it ignore that on ident

quoll17:08:04

cljs.user=> (def tx (d/transact conn {:tx-data [{:db/ident ["liz" 5] :name "Elizabeth"}]}))
#'cljs.user/tx
cljs.user=> (pprint (:tx-data @tx))
([:tg/node-5 :tg/entity true 3 true]
 [:tg/node-5 :db/ident :tg/node-6 3 true]
 [:tg/node-6 :tg/first "liz" 3 true]
 [:tg/node-6 :tg/rest :tg/node-7 3 true]
 [:tg/node-7 :tg/first 5 3 true]
 [:tg/node-6 :tg/contains "liz" 3 true]
 [:tg/node-6 :tg/contains 5 3 true]
 [:tg/node-5 :name "Elizabeth" 3 true])

quoll17:08:31

so the ident became :tg/node-6

quoll17:08:56

That won’t work on buffer-backed indexes, but I think I can do it as a new datatype with edn

jjttjj17:08:31

(I have no opinion on if it's a good idea or not, just starting to play with asami a little bit 🙂 )

quoll18:08:16

It’s an edge case that ought to be handled. Either accept it, or throw an exception. Either way, it shouldn’t get serialized into a linked list like that, since it isn’t useful (and led to confusion with at least one person)

quoll18:08:38

I made a Zuko ticket for it