Skip to content

Commit c3fee52

Browse files
committed
Version 1.2.6
1 parent 0facfa4 commit c3fee52

File tree

7 files changed

+35
-7
lines changed

7 files changed

+35
-7
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# 1.2.6
2+
3+
- Tempid resolution fails in some cases #403
4+
15
# 1.2.5
26

37
- Special case Inf/-Inf and NaN in serializer since JSON can’t hold them #402

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ The intention with DataScript is to be a basic building block in client-side app
1818
## Latest version [![Build Status](https://travis-ci.org/tonsky/datascript.svg?branch=master)](https://travis-ci.org/tonsky/datascript)
1919

2020
```clj
21-
[datascript "1.2.5"]
21+
[datascript "1.2.6"]
2222
```
2323

2424
## Support us
@@ -166,7 +166,7 @@ For more examples, see [our acceptance test suite](test/datascript/test/).
166166
DataScript can be used from any JS engine without additional dependencies:
167167

168168
```html
169-
<script src="https://github.com/tonsky/datascript/releases/download/1.2.5/datascript-1.2.5.min.js"></script>
169+
<script src="https://github.com/tonsky/datascript/releases/download/1.2.6/datascript-1.2.6.min.js"></script>
170170
```
171171

172172
or as a CommonJS module ([npm page](https://www.npmjs.org/package/datascript)):

project.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
(def version "1.2.5")
1+
(def version "1.2.6")
22

33
(defproject datascript (str version (System/getenv "DATASCRIPT_CLASSIFIER"))
44
:description "An implementation of Datomic in-memory database and Datalog query engine in ClojureScript"

release-js/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "datascript",
3-
"version": "1.2.5",
3+
"version": "1.2.6",
44
"description": "Immutable in-memory triplestore with Datalog queries",
55
"homepage": "https://github.com/tonsky/datascript",
66
"author": "Nikita Prokopov (https://github.com/tonsky)",

release-js/wrapper.prefix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Datascript v1.2.5
2+
* Datascript v1.2.6
33
*
44
* Copyright 2014-2021 Nikita Prokopov
55
*

src/datascript/db.cljc

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1376,8 +1376,11 @@
13761376
(contains? tempids old-eid)
13771377
(not= upserted-eid (get tempids old-eid)))
13781378
(retry-with-tempid initial-report report initial-es old-eid upserted-eid)
1379-
(recur (allocate-eid report old-eid upserted-eid)
1380-
(concat (explode db (assoc entity' :db/id upserted-eid)) entities)))
1379+
(recur
1380+
(-> report
1381+
(allocate-eid old-eid upserted-eid)
1382+
(update ::tx-redundant conjv (datom upserted-eid nil nil tx0)))
1383+
(concat (explode db (assoc entity' :db/id upserted-eid)) entities)))
13811384

13821385
;; resolved | allocated-tempid | tempid | nil => explode
13831386
(or (number? old-eid)

test/datascript/test/upsert.cljc

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,27 @@
190190
(is (= {:db/id 2, :name "Bob", :likes "Pizza", :age 42}
191191
(tdc/entity-map db 2)))))
192192

193+
;; https://github.com/tonsky/datascript/issues/403
194+
(deftest test-upsert-string-tempid-ref
195+
(let [db (-> (d/empty-db {:name {:db/unique :db.unique/identity}
196+
:ref {:db/valueType :db.type/ref}})
197+
(d/db-with [{:name "Alice"}]))
198+
expected #{[1 :name "Alice"]
199+
[2 :age 36]
200+
[2 :ref 1]}]
201+
(is (= expected (tdc/all-datoms
202+
(d/db-with db [{:db/id "user", :name "Alice"}
203+
{:age 36, :ref "user"}]))))
204+
(is (= expected (tdc/all-datoms
205+
(d/db-with db [[:db/add "user" :name "Alice"]
206+
{:age 36, :ref "user"}]))))
207+
(is (= expected (tdc/all-datoms
208+
(d/db-with db [{:db/id -1, :name "Alice"}
209+
{:age 36, :ref -1}]))))
210+
(is (= expected (tdc/all-datoms
211+
(d/db-with db [[:db/add -1, :name "Alice"]
212+
{:age 36, :ref -1}]))))))
213+
193214
(deftest test-vector-upsert
194215
(let [db (-> (d/empty-db {:name {:db/unique :db.unique/identity}})
195216
(d/db-with [{:db/id -1, :name "Ivan"}]))]

0 commit comments

Comments
 (0)