This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-08-21
Channels
- # announcements (15)
- # beginners (82)
- # calva (19)
- # cider (7)
- # clj-kondo (7)
- # clojure (81)
- # clojure-brasil (8)
- # clojure-dev (37)
- # clojure-europe (2)
- # clojure-italy (7)
- # clojure-nl (8)
- # clojure-spec (5)
- # clojure-uk (14)
- # clojurescript (67)
- # cursive (13)
- # datomic (29)
- # defnpodcast (2)
- # figwheel-main (19)
- # fulcro (9)
- # graalvm (5)
- # iot (3)
- # off-topic (16)
- # other-languages (1)
- # overtone (1)
- # pathom (4)
- # protorepl (2)
- # re-frame (25)
- # reagent (1)
- # shadow-cljs (126)
- # spacemacs (9)
- # sql (2)
- # test-check (24)
- # tools-deps (11)
I thought I remembered somewhere in the documentation that you can add a docstring to a transaction. Did I hallucinate that?
can you do that in list form too or just map form?
aha, ty sir!!!
Hello! get-else
works with cardinality-one attributes only? how can I chek if my cardinality-many attribute has at least one value or not, without disappearing rows with this attr is not setted?
trick with (or [?o :order/my-cardinality-many-attribute ?x] [?o :db/id ?x])
works, but it made multiple lines on many values in attribute
yes, but how can I get all missing and non-missing attr rows just with a chek of missing and without a multiplication lines?
@ivana It's not clear what query you're trying to write. Your or
clause above will return all the entities in your database because of [?o :db/id ?x]
, is it really what you want?
I want simply to check (!) if this entity have at least one value in its card-many attr or not - with the same entity lines as they are.
F.e. I have 2 entities, one with 10 values in many attr, and one with 0. I want 2 rows with bollean flag
There might be a simpler approach but something like this could work:
[:find ?o ?has-many-attr
:where
[?o :other/attr]
(or (and [?o :order/my-cardinality-many-attribute]
[(ground true) ?has-many-attr])
(and [(missing? $ ?o :order/my-cardinality-many-attribute)]
[(ground false) ?has-many-attr]))]
for the first impression it is exactly what I need, thanks alot! I'l play with it in a real queries
Datomic does not accept nil
attribute values. If I have an entity
{:foo/id 101
:foo/code :FOO
:foo/type "bar"}
and I want to update it like so:
(d/transact conn [{:foo/id 101
:foo/code :LOL
:foo/type nil}])
it will throw an Exception.
If I exclude the nil
attribute:
(d/transact conn [{:foo/id 101
:foo/code :LOL}])
:foo/type
will remain "bar"
.
:foo/type
seems like it needs to be explicitly retracted. I'm currently using the method detailed in https://matthewboston.com/blog/setting-null-values-in-datomic/ to do nil
updates. It's a red flag that I need to handroll something to do this type of update and it suggests I am not doing things in the correct way. Another approach would be a full retract and insert but I get the feeling there are unexpected behaviors I have not thought about with that approach. How are you all approaching this?You do not need to reassert the whole entity - just retract the part that is no longer true
yeah it I think misses the point. entities are sets of arbitrarily related attributes, not tables, this takes some getting used to but it’s far more powerful once you get the hang of it. And the example of “So what if we need to set a value to null?“, isn’t really. This
(datomic/q '[:find ?id ?firstname ?lastname
:in $
:where
[?id :user/firstname ?firstname]
[?id :user/lastname ?lastname]]
(datomic/db conn))
should be more like this:
(datomic/q '[:find ?id (pull ?e [:user/firstname :user/lastname])
:in $
:where
[?id :user/firstname]
; - or perhaps -
[?id :user/id]
]
(datomic/db conn))
No need to ‘simulate null’, and you keep the clean semantics of simply retracting :user/lastname
. Also ‘matching for values’ is less efficient (though probably not a big deal in this trivial case), as the engine has to do work to match each ‘clause’. to the extent possible, let your where do the selecting, then just pull
what you need in terms of valuesalso, the edit-or-create-user-txn
example seems to conflate empty strings with null/nil. Now that may be desired behavior in certain circumstances, but “” is not nil/null/“not present”, even in a traditional say relational db. Also, figuring out retracts is pretty trivial. a set/difference
on the keys of the incoming update and an existing entity will give you that directly. “” as nil, if necessary can be tacked on with filter
prior to the diff
Execution error (StackOverflowError) at cider.nrepl.middleware.out/print-stream$fn (out.clj:93). Has anyone else seen this?
Is there a function in the Peer api that allows a user to programmatically determine the transactor’s port?
We are using the map uri, with a cassandra callback, so port is not present in the uri.