We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hey @tonsky
I've noticed a behaviour that is substantially different from Datomic, and might be a bug.
I'm using datascript 1.0.3 and I've tested this behaviour both on cljs and clj.
When I'm running
(d/q '[:find ?name ?result :in $ ?my-fn :where [?e :person/name ?name] [(?my-fn) ?result] [(< ?result 3)]] (d/db-with (d/empty-db) [{:person/name "Joe"}]) (fn [] 5)) => #{}
I correctly get an empty set (result is greater than 3)
But if I do not force the evaluation of ?result the condition is never checked
?result
(d/q '[:find ?name :in $ ?my-fn :where [?e :person/name ?name] [(?my-fn) ?result] [(< ?result 3)]] (d/db-with (d/empty-db) [{:person/name "Joe"}]) (fn [] 5)) => #{["Joe"]}
The same behaviour occurs on the JVM if you call the function directly
(defn my-fn [] 5) (d/q '[:find ?name :in $ :where [?e :person/name ?name] [(user/my-fn) ?result] [(< ?result 3)]] (d/db-with (d/empty-db) [{:person/name "Joe"}])) => #{["Joe"]}
The equivalent code in Datomic produces an empty set instead.
(def conn (do (d/create-database "datomic:mem://test") (d/connect "datomic:mem://test"))) (defn my-fn [] 5) (d/q '[:find ?doc :in $ :where [?e :db/doc ?doc] [(user/my-fn) ?result] [(< ?result 3)]] (d/db conn)) => #{}
The text was updated successfully, but these errors were encountered:
Looks like a bug — I’ll take a look!
Sorry, something went wrong.
69ac944
Pushed 1.0.5, hope it fixes the issue
Update Datascript version & docs
a0e8033
tonsky/datascript#385 fixes empty predicate so there's no need to add irrelevant metadata to the tx
It does, thanks for the quick fix! 🥇
No branches or pull requests
Hey @tonsky
I've noticed a behaviour that is substantially different from Datomic, and might be a bug.
I'm using datascript 1.0.3 and I've tested this behaviour both on cljs and clj.
When I'm running
I correctly get an empty set (result is greater than 3)
But if I do not force the evaluation of
?result
the condition is never checkedThe same behaviour occurs on the JVM if you call the function directly
The equivalent code in Datomic produces an empty set instead.
The text was updated successfully, but these errors were encountered: