Skip to content
New issue

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

Expose Clojure vars to inter-fn #215

Open
huahaiy opened this issue May 30, 2023 · 0 comments
Open

Expose Clojure vars to inter-fn #215

huahaiy opened this issue May 30, 2023 · 0 comments
Labels
enhancement New feature or request

Comments

@huahaiy
Copy link
Contributor

huahaiy commented May 30, 2023

From Clojurian slack:

(ns slix.node)

(defn testing-fn []
  "test-value")

(di/definterfn test-tx1 [db tempid]
  [{:db/id tempid :node/value (slix.node/testing-fn)}])

(di/definterfn test-tx2 [db tempid]
  [{:db/id tempid :node/value "test-value"}])

(d/transact! test-conn [{:db/ident :add-node1
              :db/fn test-tx1}])

(d/transact! test-conn [{:db/ident :add-node2
              :db/fn test-tx2}])

:add-node1 fails, but :add-node2 succeeds.

This is the case, because inter-fn are interpreted by sci, which does not have direct access to Clojure vars. We should make it possible to do so.

Notice that, we do not need an inter-fn for this use case in embedded mode, we can use :db.fn/call instead, as it does not persist the function and just call it.

@huahaiy huahaiy added the enhancement New feature or request label May 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant