replikativ/datahike

[Bug]: NullPointerException trying to transact from CLI

Closed this issue · 8 comments

What version of Datahike are you using?

0.6.1547

What version of Java are you using?

openjdk 11.0.20.1

What operating system are you using?

Ubuntu 20.04.1

What database EDN configuration are you using?

{:store  {:backend :file
          :path "/home/tamayo/Downloads/testdb"
          :config {:in-place? true}}
 :keep-history? true
 :schema-flexibility :read}

Describe the bug

After downloading and extracting the CLI, I configured and created a database and then attempted to transact to it. Instead it throws a NullPointerException and prints a stack trace.

What is the expected behaviour?

Following the example usage, I expected the ./dhi transact ... command to succeed. :)

How can the behaviour be reproduced?

Download and extract datahike-0.6.1547-linux-x86_64.zip, create a database, and transact to it:

⚡  ~/Downloads $ ./dhi create-database testdb.edn                                                                                                                                                                 
{:keep-history? true, :search-cache-size 10000, :index :datahike.index/persistent-set, :store {:path "/home/tamayo/Downloads/testdb", :scope "127.0.1.1", :backend :file, :config {:in-place? true}}, :store-cache-
size 1000, :attribute-refs? false, :writer {:backend :self}, :crypto-hash? false, :schema-flexibility :read, :branch :db}                                                                                          
⚡  ~/Downloads $ ./dhi database-exists testdb.edn                                                                                                                                                                 
true                                                                                                                                                                                                               
⚡  ~/Downloads $ ./dhi transact db:testdb.edn '[[:db/add -1 :name "Coby"]]'                                                                                                                                       
Exception in thread "main" java.lang.NullPointerException                                                                                                                                                          
        at clojure.core$deref_future.invokeStatic(core.clj:2317)                                                                                                                                                   
        at clojure.core$deref.invokeStatic(core.clj:2337)                                                                                                                                                          
        at datahike.writer$transact_BANG_.invokeStatic(writer.cljc:105)                                                                                                                                            
        at datahike.api$transact.invokeStatic(api.cljc:241)                                                                                                                                                        
        at datahike.cli$_main.invokeStatic(cli.clj:192)                                                                                                                                                            
        at datahike.cli$_main.doInvoke(cli.clj:146)                                                                                                                                                                
        at clojure.lang.RestFn.applyTo(RestFn.java:137)                                                                                                                                                            
        at datahike.cli.main(Unknown Source)
whilo commented

You need to use ./dhi transact conn:testdb.edn '[[:db/add -1 :name "Coby"]]' to connect to the database. The error could definitely be better.

Ah, so it is the usual distinction between transacting on a conn vs. querying a db? In that case I believe the docs are also wrong.

whilo commented

Yes, here https://github.com/replikativ/datahike/blob/main/doc/cli.md#example-usage. I will leave this issue open until it is fixed. @acobster thanks for pointing this out! Lmk your finding for the CLI, would be helpful to get feedback!

Changing it to conn: worked. Working on a PR to update the docs!

whilo commented

@acobster Just saw your work on bread btw., pretty cool! I always wanted to have a blogging software written on top of Datahike and Clojure.

Thanks! After discovering Datomic (back when it was $1200/yr) I actually sought out Datahike specifically for Bread. :) It's gone through a lot of hammock-driven iterations, but hopefully it'll be useful soon...

whilo commented

Nice! It can take time to get things right. Datahike also took a bit more time than anticipated to shape up.

whilo commented

Closed with #643 . Thanks again!