Fork me on GitHub
Kris C08:11:38

Hello, is it possible to have (define) a composite tuple if one of the keys (tuple attributes) has a :db.cardinality/many ?


where can I read on the difference between onprem and cloud?


Is it expected that you cannot pull from the same eid in two locations in the :find of a query?

(d/q '[:find (pull ?e [:db/doc]) (pull ?e [:db/ident])
       [?e :db/ident :db/cardinality]]
  (d/db conn))
Execution error (ArrayIndexOutOfBoundsException) at datomic.core.datalog/fn$project (datalog.clj:560).
Index 1 out of bounds for length 1

Lennart Buit07:11:49

I’ve been bitten by this before too

Lennart Buit07:11:27

You can also not do {:find [?e (pull ?e [*])] …}


Creating a new var name lets you do it:

(d/q '[:find (pull ?e [:db/doc]) (pull ?e2 [:db/ident])
       [?e :db/ident :db/cardinality]
       [(identity ?e) ?e2]]
  (d/db conn))
[[#:db{:doc "Property of an attribute. Two possible values: :db.cardinality/one for single-valued attributes, and :db.cardinality/many for many-valued attributes. Defaults to :db.cardinality/one."}
  #:db{:ident :db/cardinality}]]


I'm gathering test statistics in my database, e.g. what errors were logged during a test run (so we can have stats about our tests). Would you create idents for each error type and then have an "error log" entity that has a ref attribute. Or would you make the error type something like a string?




s = symbol?


sorry that’s sed. I’m saying why consider a string when you could use an actual keyword type


yea makes way more sense


Advantage refs/enums: you can rename them easily, you can attach metadata to their entities, they can be semi-closed, self-describing (in db) enumerated sets (i.e. open, but ceremony and thought required to make new ones)

✔️ 1

Disadvantage: d/pull api returns them as entities not keywords, which can be annoying if you want to represent them as keyword values in code. You shouldn’t have a very large number (tens of thousands) of idents for performance reasons. You need to change schema to add them, which isn’t good if you don’t control the set


using keywords instead is basically the opposite tradeoffs vs the above


thanks. I get a bit the feeling for starters keywords is fine


If you use a keyword, you can still use an attribute predicate to enforce the set if you need (e.g. guard against typos), but now enlarging the set requires a deploy, not just a schema change

👍 1

Any Datomic users have strategies for generating good data sets for testing? Anyone using generative testing against the Datomic schema?


I've used clojure.test.check.generators with Datomic to do property based testing of databases over time (a single database changing over time) and "space" (a space of databases with different variations) with dev-local and d/with and it works well

👍 1