Skip to content

Commit

Permalink
Fix attribute refs bug when transacting tuple value (#696)
Browse files Browse the repository at this point in the history
Fixes issue #695

Co-authored-by: Jonas Östlund <ostlund.jobtech@gmail.com>
  • Loading branch information
jonasseglare and Jonas Östlund authored Sep 24, 2024
1 parent f85c748 commit 87aed88
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/datahike/db/transaction.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,7 @@

(defn check-tuple [db op-vec]
(let [[_ _ a v] op-vec
attr-schema (-> db dbi/-schema a)]
attr-schema (-> db dbi/-schema (get a))]
(cond (:db/tupleType attr-schema)
(cond (> (count v) 8)
(raise "Cannot store more than 8 values for homogeneous tuple: " op-vec
Expand Down
14 changes: 14 additions & 0 deletions test/datahike/test/attribute_refs/transact_test.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -189,3 +189,17 @@
(is (= (:age e) 32))
(is (:had-birthday e)))
(d/release conn)))

(deftest test-tuples
(let [conn (setup-new-connection)]
(d/transact conn [#:db{:ident :mapping/attributes,
:valueType :db.type/tuple,
:tupleTypes
[:db.type/keyword :db.type/keyword :db.type/keyword],
:cardinality :db.cardinality/many}])
(d/transact conn [{:mapping/attributes [[:mapping :mapped-id :remote-id]]}])
(is (= #{[[:mapping :mapped-id :remote-id]]}
(d/q '[:find ?v
:where [?e :mapping/attributes ?v]]
@conn)))
(d/release conn)))

0 comments on commit 87aed88

Please sign in to comment.