kibit icon indicating copy to clipboard operation
kibit copied to clipboard

-> and ->> in datomic queries

Open jramosg opened this issue 3 years ago • 0 comments

Hello,

I detected this issue, I think that this should not be suggested:

Consider using:
  (?uuids ?uuid)
instead of:
  (-> ?uuid ?uuids)

This suggestion gives error in datomic queries. For example:

(d/q
  '[:find [?uuid ...]
    :in $  ?uuids
    :where
    [?u :user/uuid ?uuid]
    [(-> ?uuid ?uuids)]]
  (d/db conn) #{"1" "2"})
=> ["1"]

The error

(d/q
  '[:find [?uuid ...]
    :in $ ?uuids
    :where
    [?u :user/uuid ?uuid]
    [(?uuids ?uuid)]]
  (d/db conn) #{"1" "2"})

CompilerException java.lang.RuntimeException: Unable to resolve symbol: ?uuids in this context, compiling:(/private/var/folders/9l/9jbpng7x7_j1jkm5l7gh1zg80000gn/T/form-init10140150991526075454.clj:6:6) 

The plugin suggests this, but datomic does not accepted. I think it could be okay to look if it is inside a datomic query to avoid it.

(def ?uuids #{"1" "2"})
(?uuids "2")
=> "2"

jramosg avatar Jun 17 '21 13:06 jramosg