Fork me on GitHub
#datomic
<
2019-12-26
>
enn18:12:15

After retracting an entity (using the retractEntity transaction fn), what should I expect when I call d/entity with the now-retracted entity's ID?

benoit18:12:47

Same thing as if you were passing an entity id that does not exist. I think it returns an "empty entity", not nil.

potetm20:12:43

The whole concept of “entity” is layered on top of Facts. retractEntity is a shorthand for “retract all Facts with this entity ID in the e slot.” There is no concept for “remove this entity.” So, like Benoit said, d/entity always returns something. Even if that something happens to have no Facts in the db.

codonnell20:12:09

I have a dependency (fulcro) in my ion code that depends on transit-clj 0.8.313. In particular, it uses the metadata support, which was introduced in transit-clj 0.8.303. Unfortunately, according to the ion push output, the datomic process overrides this transitive dependency with transit-clj 0.8.285 which doesn't include metadata support and tanks my deployment. Are my only two options trying to downgrade my fulcro dependency to some point where it doesn't use the metadata support and waiting for the Datomic team to upgrade the transit-clj version? For reference, 0.8.285 was released in 2015; metadata support was introduced in March of 2018.

Jacob O'Bryant17:12:39

@U0DUNNKT2 I had the same exact problem a couple weeks ago. I believe those are basically the only two options. Hopefully cognitect will update the deps at some point. In the mean time, I just patched fulcro:

diff --git a/src/main/com/fulcrologic/fulcro/algorithms/transit.cljc b/src/main/com/fulcrologic/fulcro/algorithms/transit.cljc
index bcc73f02..4a924e76 100644
--- a/src/main/com/fulcrologic/fulcro/algorithms/transit.cljc
+++ b/src/main/com/fulcrologic/fulcro/algorithms/transit.cljc
@@ -101,12 +101,11 @@
   shadow-cljs, this means placing that in your package.json file (not relying on the jar version)."
   ([data] (transit-clj->str data {}))
   ([data opts]
-   (let [opts (assoc opts :transform t/write-meta)]
-     #?(:cljs (t/write (writer opts) data)
-        :clj
-              (with-open [out (.ByteArrayOutputStream.)]
-                (t/write (writer out opts) data)
-                (.toString out "UTF-8"))))))
+   #?(:cljs (t/write (writer opts) data)
+      :clj
+      (with-open [out (.ByteArrayOutputStream.)]
+        (t/write (writer out opts) data)
+        (.toString out "UTF-8")))))
 
 (defn transit-str->clj
   "Use transit to decode a string into a clj data structure. Useful for decoding initial app state

Jacob O'Bryant18:12:08

Also, FYI, I had to add :exclusions [org.clojure/clojurescript] to fulcro because of another ion dependency conflict.

codonnell18:12:04

@U7YNGKDHA Thanks! Are you maintaining a fork of fulcro somewhere with these changes?

Jacob O'Bryant18:12:18

no, for now I've just got the patch applied to a local clone

Jacob O'Bryant18:12:45

(the :exclusions [org.clojure/clojurescript is for your project's deps.edn btw, fulcro {:local/root "../fulcro" :exclusions [org.clojure/clojurescript]} to be specific, not another patch of fulcro)

👍 3
henrik18:12:40

This is good to know! Was planning to look into deploying Fulcro on Ions. Updates to Ion deps seem to happen extremely conservatively, don’t expect a bump anytime soon (if history is anything to go by).

souenzzo03:12:08

You can create a com.fulcrologic.fulcro.algorithms.transit namespace in your src and maintain your own version of this ns

codonnell03:12:39

A variant of this was suggested in #fulcro: adding a no-op definition of the cognitect.transit/write-meta function to my codebase so that the fulcro namespaces compiles. I prefer this to redefining the fulcro transit namespace, personally.

👍 1