This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-11-10
Channels
- # asami (41)
- # babashka (24)
- # beginners (48)
- # calva (41)
- # cider (10)
- # clj-commons (20)
- # clj-kondo (2)
- # cljdoc (8)
- # clojure (131)
- # clojure-australia (4)
- # clojure-europe (17)
- # clojure-hungary (2)
- # clojure-india (2)
- # clojure-nl (3)
- # clojure-uk (1)
- # clojurescript (12)
- # community-development (6)
- # core-logic (4)
- # cursive (11)
- # datomic (22)
- # emacs (25)
- # events (1)
- # exercism (2)
- # fulcro (30)
- # helix (5)
- # honeysql (6)
- # hugsql (3)
- # integrant (12)
- # introduce-yourself (4)
- # lsp (5)
- # malli (5)
- # nextjournal (31)
- # off-topic (4)
- # pedestal (3)
- # portal (51)
- # reitit (33)
- # remote-jobs (1)
- # shadow-cljs (12)
- # sql (10)
- # vim (7)
- # xtdb (37)
Hello, is it possible to have (define) a composite tuple if one of the keys (tuple attributes) has a :db.cardinality/many
?
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])
:where
[?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
Created an ask on this since it seems like a bug: https://ask.datomic.com/index.php/682/pull-identical-var-in-two-find-positions
I’ve been bitten by this before too
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])
:where
[?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?
sorry that’s sed. I’m saying why consider a string when you could use an actual keyword type
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)
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
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
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