Fork me on GitHub
#datomic
<
2023-12-12
>
Tyler Nisonoff02:12:04

I believe I have a repro for incorrect behavior of the :default option in a pull. When the attribute's value is false , the default will override it:

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

; insert schema and entity
(let [_      (d/create-database client {:db-name "repro"})
      con    (d/connect client {:db-name "repro"})
      schema [{:db/ident       :account/name
               :db/valueType   :db.type/string
               :db/unique      :db.unique/identity
               :db/cardinality :db.cardinality/one}
              {:db/ident       :account/active?
               :db/valueType   :db.type/boolean
               :db/cardinality :db.cardinality/one}]
      acct   {:account/name    "test"
              :account/active? false}]
  (d/transact con {:tx-data schema})
  (d/transact con {:tx-data [acct]}))

; query without default
(let [con (d/connect client {:db-name "repro"})]
  (d/pull (d/db con)
          '[:account/name
            :account/active?]
          [:account/name "test"]))
; => :account{:name "test", :active? false}


; query with default
(let [con (d/connect client {:db-name "repro"})]
  (d/pull (d/db con)
          '[:account/name
            [:account/active? :default true]]
          [:account/name "test"]))
; => :account{:name "test", :active? true}

Joe Lane03:12:29

Thanks for the repro Tyler! I believe we actually have a fix for this already implemented and slated for our upcoming release.

jaret19:12:40

Yeah the fix is in the next release which is currently being release tested and will hopefully be out this month.

jaret12:12:16

FYI @U016TR1B18E the release is now out. 1.0.7075 has this fix for Pro. Cloud will be coming later this week. https://forum.datomic.com/t/datomic-1-0-7075-pro-now-available/2345

❤️ 1