datascript

Immutable database and Datalog query engine for Clojure, ClojureScript and JS
Oliver George 2019-11-19T12:26:25.048100Z

I'm getting a "Lookup ref attribute should be marked as :db/unique" but only with advanced compilation. It's driving me crazy.

Oliver George 2019-11-19T12:26:41.048500Z

Not looking for answers but is there a support group I can join?

cjsauer 2019-11-19T13:57:27.049500Z

@olivergeorge shot in the dark, but this helped me when I was having advanced compilation trouble with DataScript: https://github.com/tonsky/datascript/wiki/Tips-&-tricks#externs-and-shadow-cljs

cjsauer 2019-11-19T13:57:58.049900Z

Not sure about a support group other than here.

Oliver George 2019-11-19T21:55:11.051500Z

Thanks for sharing @cjsauer. Not using shadow-cljs and I think externs are where they should be ... we'll see. I need to get to a minimal test case.

Oliver George 2019-11-19T22:22:04.053400Z

Here's my test case.

(let [db (d/empty-db {:sighting/id    {:db/unique :db.unique/identity}
                        :user/sightings {:db/cardinality :db.cardinality/many :db/valueType :db.type/ref}})
        tx-data [{:user/sightings [{:sighting/id 123}]}]]
    (try (d/db-with db tx-data)
         (js/alert "Success")
         (catch js/Object e
           (js/alert (.-message e)))))

Oliver George 2019-11-19T22:22:20.053800Z

Really hoping someone will tell me I'm doing something obvious.

Oliver George 2019-11-19T22:22:45.054100Z

Fails with this error "Lookup ref should contain 2 elements: [{:sighting/id 123}]"

Oliver George 2019-11-19T22:23:15.054700Z

But only fails with iOS simulator running release configuration.

Oliver George 2019-11-19T22:23:38.055200Z

So it seems like some assumption in the CLJS code isn't always true.

Oliver George 2019-11-19T22:23:50.055600Z

It's a re-natal project.

Oliver George 2019-11-19T22:24:05.055900Z

Need to do more testing of combinations etc.