This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-01-03
Channels
- # announcements (2)
- # babashka (66)
- # beginners (225)
- # braveandtrue (1)
- # calva (14)
- # circleci (1)
- # clj-kondo (36)
- # cljsrn (3)
- # clojure (423)
- # clojure-finland (7)
- # clojure-nl (1)
- # clojure-spec (14)
- # clojure-survey (41)
- # clojure-sweden (2)
- # clojure-uk (13)
- # clojurescript (59)
- # community-development (10)
- # cursive (2)
- # datascript (14)
- # datomic (63)
- # events (3)
- # expound (8)
- # figwheel-main (6)
- # kaocha (8)
- # luminus (6)
- # malli (1)
- # nrepl (2)
- # off-topic (51)
- # other-lisps (3)
- # reagent (16)
- # shadow-cljs (44)
- # spacemacs (7)
- # sql (22)
- # vrac (1)
(Reposting from #datascript, hoping someone here may recognize this.) Ran into a very bizarre case. After compiling React-Native (Expo) app with shadow-cljs, datascript queries return nothing or very strange results
;; require
[datascript.core :as ds-db]
(let [test-db (db/create-conn {:id {:db/index true
:db/cardinality :db.cardinality/one}})
tx (db/transact test-db [{:id 1
:text "this is a test"}])
query (db/q '[:find ?text
:in $
:where
[?e :id 1]
[?e :text ?text]]
(db/db test-db))]
(println "test-db=" test-db)
(if-not (= query "this is a test")
{:result :failed
:query-return query}
{:result :success
:query-return query}))
Failed return (on latest datascript 0.18.8
):
test-db= #object[cljs.core.Atom {:val #datascript/DB {
:schema {:id {:db/index true, :db/cardinality :db.cardinality/one}},
:datoms [[1 :id 1 536870913] [1 :text "this is a test" 536870913]]}}]
{:result :failed, :query-return #{[2162164496]}}
Note the strange return value of #{[2162164496]}
.
However, running it in development mode produces the expected query-return of #{[this is a test]}
Anyone have a theory about why this is happening or what the returned value is?@quest I think datascript requires manual externs. can't remember the details but I think including :compiler-options {:externs ["datascript/externs.js"]}
in your build config fixes it
👍 4
@thheller That did the trick. Your memory was correct, someone was kind enough to link me https://github.com/tonsky/datascript/wiki/Tips-&-tricks#externs-and-shadow-cljs which suggests the same tweak. Thank you 🙇
👍 4