Welcome! Please see the About page for a little more info on how this works.

+1 vote
in Client API by

Environment

  • com.datomic/client-cloud 1.0.119
  • com.datomic/dev-local 1.0.242

History

Reproducible in both dev-local and Cloud client implementations.

(require '[datomic.client.api :as d])

(def client (d/client {:server-type :dev-local
                       :system      "test"
                       :storage-dir :mem}))

(d/create-database client {:db-name "bug-example"})

(def conn (d/connect client {:db-name "bug-example"}))

(d/transact conn {:tx-data [{:db/ident       :name
                             :db/valueType   :db.type/string
                             :db/cardinality :db.cardinality/one}]})

(def tx-report
  (d/transact conn {:tx-data [{:db/id "a"
                               :name  "kenny"}]}))

(def db-id (get-in tx-report [:tempids "a"]))

(d/pull (d/db conn)
  [:db/id]
  db-id)
=> {:db/id 83562883711050, :name "kenny"}

Expectation

Issuing d/pull with a selection of [:db/id] will only pull the :db/id attribute.

Actual

Issuing d/pull with a selection of [:db/id] will only pull all attributes on the given entity.

Evidence

See repro in History.

Impact

This bit me when doing some debugging in the REPL. I was trying to just get the db/id of a "top-level" entity, and it pulled the whole thing. This top-level entity is massive and resulted in me needing to restart my REPL. The ability to pull the entirety of an entity is a bit frightening, especially if such a thing were to happen (on purpose or accident) in production. The use of a [*] pull pattern is almost always avoided for this reason. Tracking down a bug like this could be quite tricky since it looks so innocent by appearance.

Please log in or register to answer this question.

...