Fork me on GitHub
#datascript
<
2022-02-23
>
johanatan20:02:34

hi, could someone please explain why the following predicate expression isn't filtering out the keyword mentioned:

core=> (cljs.pprint/pprint (d/q `[:find [?k ...] :where [?e :root/user ?r][?r ?k ?v][('not= ?k :user/feature-flags)]] @connection))
[:user/id
 :user/disable-global-role?
 :user/has-to-accept-license?
 :user/first-name
 :user/last-name
 :user/feature-flags
 :user/role
 :user/company-id 
 :user/avatar-url 
 :user/app-roles 
 :user/email]
nil

johanatan20:02:36

I in fact get the same result if i toggle the not= to = (which violates boolean algebra). this indicates to me that the predicate isn't even running (and a println inside the predicate also confirms that [with a custom, user-defined predicate and the attending :in clause to bring it in]).

johanatan20:02:14

this is the result with =:

core=> (cljs.pprint/pprint (d/q `[:find [?k ...] :where [?e :root/user ?r][?r ?k ?v][('= ?k :user/feature-flags)]] @connection))
[:user/id
 :user/disable-global-role?
 :user/has-to-accept-license?
 :user/first-name
 :user/last-name
 :user/feature-flags
 :user/role
 :user/company-id 
 :user/avatar-url 
 :user/app-roles 
 :user/email]
nil

metasoarous21:02:06

I think your problem may be that you're quoting the '= and 'not= symbols.

👍 1
metasoarous21:02:04

You're already inside an outer [:find ...] quote there, so this would not produce the desired result

metasoarous21:02:09

user=> `[:find 'not]
[:find (quote clojure.core/not)]

johanatan21:02:50

Yes but strangely datascript does not throw the unknown predicate error

johanatan21:02:33

I actually wanted backtick so I could use # to get unique variable syms

johanatan21:02:56

But yea btw this conversation already occurred in #datomic

johanatan21:02:08

Thanks for reaching out though