datahike icon indicating copy to clipboard operation
datahike copied to clipboard

[Bug]: Map notation for transactions not working well with temp-ids

Open Heliosmaster opened this issue 3 years ago • 1 comments

What version of Datahike are you using?

0.4.1478

What version of Java are you using?

openjdk version "11.0.10" 2021-01-19

What operating system are you using?

MacOS

What database EDN configuration are you using?

{:store {:backend :file :path "db"}})

Describe the bug

Trying to transact some stuff (see repro) gets an error:

2022-01-03T18:35:54.936Z Joel.local ERROR [datahike.db:1266] - Expected number or lookup ref for entity id, got  -1000001 {:error :entity-id/syntax, :entity-id -1000001}
2022-01-03T18:35:55.112Z Joel.local ERROR [datahike.connector:85] - Error during transaction Expected number or lookup ref for entity id, got -1000001
Execution error (ExceptionInfo) at datahike.db/entid (db.cljc:1266).
Expected number or lookup ref for entity id, got -1000001

What is the expected behaviour?

That transacting works. Using vector notation it works (see repro)

How can the behaviour be reproduced?

Schema:

   {:db/ident       :foo/inserted-at
    :db/valueType   :db.type/instant
    :db/cardinality :db.cardinality/one}
   {:db/ident       :foo/match
    :db/valueType   :db.type/ref
    :db/cardinality :db.cardinality/one
    :db/unique      :db.unique/identity}

Repro:

(d/transact db-conn [{:foo/inserted-at (Date.)}]) ;; db/id is 16
(d/transact db-conn [{:db/id -1000001
                      :foo/match 16}
                     {:db/id 16
                      :foo/match -1000001}])

Using the vector notation, i.e.

(d/transact db-conn [{:db/id -1000001
                        :foo/match 16}
                       [:db/add 16 :foo/match -1000001]])

works

Heliosmaster avatar Jan 03 '22 19:01 Heliosmaster

Easier to investigate after the refactoring of the DB namespace, as this should separate the map notation part and the vector notation part of transactions.

jsmassa avatar May 30 '22 14:05 jsmassa