Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uncaught Error: compare on non-nil objects of different types #38

Closed
scttnlsn opened this issue Oct 29, 2014 · 3 comments
Closed

Uncaught Error: compare on non-nil objects of different types #38

scttnlsn opened this issue Oct 29, 2014 · 3 comments

Comments

@scttnlsn
Copy link

I'm getting this error occasionally when calling transact!. The only pattern I could find possibly has something to do with the underscores in the following example...

This always throws an error:

(d/transact! conn [{:db/id -1 :test/foo "foo" :test/_bar {:baz "qux"}}])

But these always work fine:

(d/transact! conn [{:db/id -1 :test/foo "foo" :test/bar {:baz "qux"}}])
(d/transact! conn [{:db/id -1 :test/_bar {:baz "qux"}}])
(d/transact! conn [{:db/id -1 :test/foo "foo" :test/_bar 123}])

Here's the JavaScript stack trace:

compare (core.cljs:1521)
cmp (core.cljs:44)
cmp_datoms_eavt (core.cljs:48)
binary_search_l (btset.cljs:33)
_seek (btset.cljs:382)
_slice (btset.cljs:404)
datascript.btset.slice.slice__3 (btset.cljs:414)
datascript.btset.slice.slice (btset.cljs:412)
datascript.btset.slice.slice__2 (btset.cljs:411)
datascript.btset.slice.slice (btset.cljs:412)
datascript.core.DB.datascript$core$ISearch$_search$arity$2 (core.cljs:80)
_search (core.cljs:31)
transact_add (core.cljs:192)
transact_tx_data (core.cljs:249)
with$ (datascript.cljs:37)
(anonymous function) (datascript.cljs:45)
cljs.core.swap_BANG_.swap_BANG___2 (core.cljs:3348)
cljs.core.swap_BANG_.swap_BANG_ (core.cljs:3358)
_transact_BANG_ (datascript.cljs:44)
transact_BANG_ (datascript.cljs:51)

Any ideas?

@tonsky
Copy link
Owner

tonsky commented Oct 29, 2014

Underscores sure are a problem. When you write [:db/add X :test/_bar Y] it reads backwards, meaning “put a reference from Y to X via :test/bar property”. So it expects both X and Y to be integers. In your case, you put hashmap at Y pos, and that wouldn’t work as an entity id.

So two problems for me to fix here:

  1. Error message should be improved (sorry about that)

  2. Error should be thrown in second case (you don’t get it here by pure luck):

    (d/transact! conn [{:db/id -1 :test/_bar {:baz "qux"}}])

@scttnlsn
Copy link
Author

@tonsky Okay, thanks. I'll have to read the Datomic docs about this. I don't get any error when there's only a single attribute (like no. 2 above).

@tonsky
Copy link
Owner

tonsky commented Oct 29, 2014

datomic allows to specify maps when creating nested relation, but ds does not support this feature yet. what about backward relation, I'm no sure that even datomic supports that=

@tonsky tonsky closed this as completed in 5ab2f99 Jan 19, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants