Skip to content

Transaction append annotation fails on IPersistentMap #220

@kyleerhabor

Description

@kyleerhabor

It seems that a transaction using the + append annotation will fail when a map is supplied. For reference, I'm using Asami 2.2.1 and Clojure 1.10.3.855.

(def conn (d/connect "asami:local://demo"))
#'hue.server.core/conn

(d/transact conn [{:title "Demo"
                   :description "This is a demonstration of the append annotation failing on maps."
                   :contents [{:statement "Wow"}]}])
#object[java.util.concurrent.CompletableFuture 0x4e0964bb "java.util.concurrent.CompletableFuture@4e0964bb[Completed normally]"]

(d/entity (d/db conn) (asami.graph/new-node 1))
{:title "Demo",
 :description "This is a demonstration of the append annotation failing on maps.",
 :contents [{:statement "Wow"}]}
 
(d/transact conn [{:db/id (asami.graph/new-node 1)
                   :contents+ {:statement "What?"}}])
; Execution error (IllegalArgumentException) at asami.durable.encoder/eval22954$fn$G (encoder.clj:107).
; No implementation of method: :encapsulate-id of protocol: #'asami.durable.encoder/FlatFile found for class: clojure.lang.PersistentArrayMap

As FlatFile does not implement the encapsulate-id function for IPersistentMap, this error seems like expected behavior (or temporary).

IPersistentMap
(header [this len]
(general-header (type->code IPersistentMap) len))
(body [this]
;; If this is an identified object, then save it's location
(doseq [id-attr [:db/id :db/ident :id]]
(when-let [id (id-attr this)]
(vswap! *entity-offsets* assoc id @*current-offset*)))
(body (apply concat (seq this))))

If it's the case, how can I append a map to a vector? I could use the ' replacement annotation and set the vector as its previous items with the new one appended, but it seems inefficient and unintended.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions