juji-io / datalevin

A simple, fast and versatile Datalog database
https://github.com/juji-io/datalevin
Eclipse Public License 1.0
1.07k stars 60 forks source link

Queries inside an inter-fn doesn't resolve a built-in properly #217

Open JeremS opened 12 months ago

JeremS commented 12 months ago

Hello, I am having a bit of an issue with the declaration of a transaction function. I have something like this:

(di/inter-fn  [db es]
 (let [n (d/q '[:find (max ?n) . 
                :where [?id :picture/number ?n]] db)]))

The problem is that when I use this fn, it is as if the (max ?n) . part of the query is processed just as ?n .

When I eval this declaration I get:

#datalevin/inter-fn (fn
                       [db es]  
                       (clojure.core/let
                        [n     
                         (datalevin.core/q  
                          '[:find
                            (clojure.core/max ?n)
                            .
                            :where
                            [?id :picture/number ?n]]
                          db)]))

The symbol max in the query is qualified to clojure.core/max instead of staying unqualified to get the aggregate behavior.

Cheers,

huahaiy commented 10 months ago

I could not seem to reproduce this. Could you isolate a test case?