Fork me on GitHub
#datalevin
<
2021-12-13
>
timmw00:12:12

Hi. Are custom query functions supported? I'm using the datalevin babashka pod and get the following error when trying to use a custom query function: Unknown function 'my-fn in [(my-fn) ?greeting]

(defn my-fn
    []
    "hello")

  (d/q '[:find ?greeting
         :in $
         :where
         [(my-fn) ?greeting]]
       (d/db conn))

Huahai05:12:29

Query function is supported in Datalevin if you use from Clojure. But if you are using babashka, you will need to make sure your function is available for Datalevin’s sci (https://github.com/babashka/sci)

Huahai05:12:48

i have not tried this use case, so if you want to do some investigation and figure out what’s missing, that would be great

Huahai05:12:04

datalevin uses its own copy of sci, so it does not know about your function that’s defined in babashka’s sci

Huahai05:12:23

i think that’s the issue

Huahai05:12:03

if you don’t have time to investigate, file an issue, i will see if I can get around to take a look

timmw09:12:44

Thanks. I'll do some investigation later on and file an issue if I'm not able to figure it out

timmw20:12:55

@U0A74MRCJ I did some investigation but unfortunately I was defeated. I think I'd need to learn more about how babashka pods work and clojure in general to know the correct approach to take here. I resorted to creating an issue https://github.com/juji-io/datalevin/issues/85 I'm happy to help with testing if you do get round to looking into this. In the meantime, I'm tempted to switch my project over to using clojure instead of babashka.