Skip to content

Commit

Permalink
Version 1.3.12
Browse files Browse the repository at this point in the history
  • Loading branch information
tonsky committed Mar 15, 2022
1 parent 47880bb commit 5aeb57f
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 7 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 1.3.12

- Fixed pull with reverse component references #430

# 1.3.11

- Fixed serializable/from-serializable for JS interop #429
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ The intention with DataScript is to be a basic building block in client-side app
## Latest version [![Build Status](https://travis-ci.org/tonsky/datascript.svg?branch=master)](https://travis-ci.org/tonsky/datascript)

```clj
[datascript "1.3.11"]
[datascript "1.3.12"]
```

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

```html
<script src="https://github.com/tonsky/datascript/releases/download/1.3.11/datascript-1.3.11.min.js"></script>
<script src="https://github.com/tonsky/datascript/releases/download/1.3.12/datascript-1.3.12.min.js"></script>
```

or as a CommonJS module ([npm page](https://www.npmjs.org/package/datascript)):
Expand Down
2 changes: 1 addition & 1 deletion deps.edn
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@

:nrepl {
:extra-deps {
nrepl/nrepl {:mvn/version "0.8.3"}
nrepl/nrepl {:mvn/version "0.9.0"}
lambdaisland/deep-diff2 {:mvn/version "2.0.108"}
}
}
Expand Down
2 changes: 1 addition & 1 deletion project.clj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(def version "1.3.11")
(def version "1.3.12")

(defproject datascript (str version (System/getenv "DATASCRIPT_CLASSIFIER"))
:description "An implementation of Datomic in-memory database and Datalog query engine in ClojureScript"
Expand Down
2 changes: 1 addition & 1 deletion release-js/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "datascript",
"version": "1.3.11",
"version": "1.3.12",
"description": "Immutable in-memory triplestore with Datalog queries",
"homepage": "https://github.com/tonsky/datascript",
"author": "Nikita Prokopov (https://github.com/tonsky)",
Expand Down
2 changes: 1 addition & 1 deletion release-js/wrapper.prefix
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Datascript v1.3.11
* Datascript v1.3.12
*
* Copyright 2014-2021 Nikita Prokopov
*
Expand Down
9 changes: 8 additions & 1 deletion src/datascript/pull_api.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -219,9 +219,16 @@
[(ReverseAttrsFrame. seen recursion-limits acc pattern attr attrs id)
(MultivalRefAttrFrame. seen recursion-limits (transient []) pattern attr datoms)]))))

(defn- auto-expanding? [^PullAttr attr]
(or
(.-recursive? attr)
(and
(.-component? attr)
(.-wildcard? ^PullPattern (.-pattern attr)))))

(defn ref-frame [context seen recursion-limits pattern ^PullAttr attr id]
(cond+
(and (not (.-recursive? attr)) (not (.-component? attr)))
(not (auto-expanding? attr))
(attrs-frame context seen recursion-limits (.-pattern attr) id)

(seen id)
Expand Down
13 changes: 13 additions & 0 deletions test/datascript/test/pull_api.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,19 @@
(is (= (str "Person-" (dec depth))
(:name (get-in pulled path))))))

; https://github.com/tonsky/datascript/issues/430
(deftest test-component-reverse
(let [schema {:ref {:db/valueType :db.type/ref
:db/isComponent true}}
db (d/db-with (d/empty-db schema)
[{:name "1"
:ref {:name "2"
:ref {:name "3"}}}])]
(is (= {:name "1", :ref {:name "2", :ref {:name "3", :_ref {:name "2"}}}}
(d/pull db
[:name {:ref [:name {:ref [:name {:_ref [:name]}]}]}]
1)))))

(deftest test-lookup-ref-pull
(is (= {:name "Petr" :aka ["Devil" "Tupen"]}
(d/pull test-db '[:name :aka] [:name "Petr"])))
Expand Down

0 comments on commit 5aeb57f

Please sign in to comment.