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

NullPointerException for simple query #15

Closed
mgerlach-klick opened this Issue Dec 26, 2018 · 1 comment

Comments

Projects
2 participants
@mgerlach-klick
Copy link

mgerlach-klick commented Dec 26, 2018

Hey, with the file /tmp/example.edn with this content:

#datahike/Datom [1 :user/name "max" 536870913 true]
#datahike/Datom [9 :comment/upvotes 1 536870914 true]

then this code:

  (let [schema { :user/name {:db/type        :db.type/string
                             :db/unique      :db.unique/identity}

                :comment/upvotes {:db/valueType   :db.type/ref
                                   :db/cardinality :db.cardinality/many
                                   :db/isComponent true}}
        dburl "datahike:file:///tmp/example.db"
        _     (datahike.api/delete-database dburl)
        _ (datahike.api/create-database-with-schema dburl schema)
        conn (datahike.api/connect dburl)]

    (datahike.migrate/import-db conn "/tmp/example.edn")

    (d/q '[:find ?cid
           :in $ ?uname
           :where
           [?uid :user/name ?uname]
           [?cid :comment/upvotes ?uid]]
         "max"))

throws a big NPE:

java.lang.NullPointerException
	at clojure.lang.Numbers.ops(Numbers.java:1018)
	at clojure.lang.Numbers.equiv(Numbers.java:217)
	at clojure.lang.Numbers.equiv(Numbers.java:213)
	at clojure.lang.Numbers.equiv(Numbers.java:3933)
	at datahike.db$eval17132$fn__17133.invoke(db.cljc:326)
	at hitchhiker.tree.core$eval13502$fn__13503$G__13493__13510.invoke(core.cljc:114)
	at hitchhiker.tree.messaging$eval14581$lookup_fwd_iter__14587$fn__14589.invoke(messaging.cljc:264)
	at clojure.core$drop_while$step__5661.invoke(core.clj:2966)
	at clojure.core$drop_while$fn__5664.invoke(core.clj:2969)
	at clojure.lang.LazySeq.sval(LazySeq.java:40)
	at clojure.lang.LazySeq.seq(LazySeq.java:49)
	at clojure.lang.RT.seq(RT.java:528)
	at clojure.lang.SeqIterator.hasNext(SeqIterator.java:38)
	at clojure.lang.TransformerIterator.step(TransformerIterator.java:74)
	at clojure.lang.TransformerIterator.hasNext(TransformerIterator.java:97)
	at clojure.lang.RT.chunkIteratorSeq(RT.java:510)
	at clojure.core$sequence.invokeStatic(core.clj:2654)
	at clojure.core$sequence.invoke(core.clj:2639)
	at datahike.db$slice.invokeStatic(db.cljc:491)
	at datahike.db$slice.invoke(db.cljc:439)
	at datahike.db$slice.invokeStatic(db.cljc:441)
	at datahike.db$slice.invoke(db.cljc:439)
	at datahike.db.DB._search(db.cljc:503)
	at datahike.query$lookup_pattern_db.invokeStatic(query.cljc:363)
	at datahike.query$lookup_pattern_db.invoke(query.cljc:360)
	at datahike.query$lookup_pattern.invokeStatic(query.cljc:395)
	at datahike.query$lookup_pattern.invoke(query.cljc:392)
	at datahike.query$_resolve_clause.invokeStatic(query.cljc:628)
	at datahike.query$_resolve_clause.invoke(query.cljc:616)
	at datahike.query$resolve_clause.invokeStatic(query.cljc:642)
	at datahike.query$resolve_clause.invoke(query.cljc:634)
	at clojure.lang.PersistentVector.reduce(PersistentVector.java:341)
	at clojure.core$reduce.invokeStatic(core.clj:6747)
	at clojure.core$reduce.invoke(core.clj:6730)
	at datahike.query$_q.invokeStatic(query.cljc:645)
	at datahike.query$_q.invoke(query.cljc:644)
	at datahike.query$q.invokeStatic(query.cljc:769)
	at datahike.query$q.doInvoke(query.cljc:754)
	at clojure.lang.RestFn.invoke(RestFn.java:439)
	at maxapp.comment.upvote$eval68731.invokeStatic(form-init3536000562099756439.clj:15)
	at maxapp.comment.upvote$eval68731.invoke(form-init3536000562099756439.clj:1)
	at clojure.lang.Compiler.eval(Compiler.java:7062)
	at clojure.lang.Compiler.eval(Compiler.java:7025)
	at clojure.core$eval.invokeStatic(core.clj:3206)
	at clojure.core$eval.invoke(core.clj:3202)
	at clojure.main$repl$read_eval_print__8572$fn__8575.invoke(main.clj:243)
	at clojure.main$repl$read_eval_print__8572.invoke(main.clj:243)
	at clojure.main$repl$fn__8581.invoke(main.clj:261)
	at clojure.main$repl.invokeStatic(main.clj:261)
	at clojure.main$repl.doInvoke(main.clj:177)
	at clojure.lang.RestFn.applyTo(RestFn.java:137)
	at clojure.core$apply.invokeStatic(core.clj:657)
	at clojure.core$apply.invoke(core.clj:652)
	at refactor_nrepl.ns.slam.hound.regrow$wrap_clojure_repl$fn__59911.doInvoke(regrow.clj:18)
	at clojure.lang.RestFn.invoke(RestFn.java:1523)
	at clojure.tools.nrepl.middleware.interruptible_eval$evaluate$fn__47777.invoke(interruptible_eval.clj:87)
	at clojure.lang.AFn.applyToHelper(AFn.java:152)
	at clojure.lang.AFn.applyTo(AFn.java:144)
	at clojure.core$apply.invokeStatic(core.clj:657)
	at clojure.core$with_bindings_STAR_.invokeStatic(core.clj:1965)
	at clojure.core$with_bindings_STAR_.doInvoke(core.clj:1965)
	at clojure.lang.RestFn.invoke(RestFn.java:425)
	at clojure.tools.nrepl.middleware.interruptible_eval$evaluate.invokeStatic(interruptible_eval.clj:85)
	at clojure.tools.nrepl.middleware.interruptible_eval$evaluate.invoke(interruptible_eval.clj:55)
	at clojure.tools.nrepl.middleware.interruptible_eval$interruptible_eval$fn__47822$fn__47825.invoke(interruptible_eval.clj:222)
	at clojure.tools.nrepl.middleware.interruptible_eval$run_next$fn__47817.invoke(interruptible_eval.clj:190)
	at clojure.lang.AFn.run(AFn.java:22)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:745)

Am I doing something wrong? This looks pretty straightforward to me?

@mgerlach-klick

This comment has been minimized.

Copy link

mgerlach-klick commented Dec 26, 2018

Reducing it further, this is enough to make it throw up:

/tmp/example.edn:

#datahike/Datom [1 :user/name "max" 536870913 true]
#datahike/Datom [9 :comment/upvotes 1 536870914 true]

code:

  (let [schema {:user/name {:db/type   :db.type/string
                            :db/unique :db.unique/identity}
                :comment/upvotes {:db/valueType   :db.type/ref
                                  :db/cardinality :db.cardinality/many}}
        dburl "datahike:file:///tmp/example.db"
        _     (datahike.api/delete-database dburl)
        _     (datahike.api/create-database-with-schema dburl schema)
        conn  (datahike.api/connect dburl)]

    (datahike.migrate/import-db conn "/tmp/example.edn")

    (d/q '[:find ?cid
           :where [?cid :comment/upvotes _]]))

@kordano kordano added this to To do in Development via automation Jan 16, 2019

@kordano kordano added the bug label Jan 16, 2019

@whilo whilo closed this in f5ad20b Jan 21, 2019

Development automation moved this from To do to Done Jan 21, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment