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
Suppose I have the following function to keep track of my singleton database IDs:
(def kwd->id (let [ids (atom {})] (fn [kwd] (kwd (swap! ids #(assoc %1 kwd (get %1 kwd (int (gensym "")))))))))
And this initial DB state:
(def ^:private initial-db-state [{;; :db/ident :timerange ;; cannot use :db/ident yet due to: https://github.com/denistakeda/re-posh/issues/41 :id (kwd->id :timerange) :timerange/timerange {:timerange "24h"}}])
Then the following query does not yield the correct result and instead gives the error "Tuple binding cannot be empty":
(rp/reg-query-sub ::timerange (let [id (kwd->id :timerange)] `[:find ?t . :where [~id :timerange/timerange ?t]]))
I also tried inlining the ID retrieval:
(rp/reg-query-sub ::timerange `[:find ?t . :where [~(kwd->id :timerange) :timerange/timerange ?t]])
The text was updated successfully, but these errors were encountered:
I have verified that this is not a problem with the following query:
(rp/reg-query-sub ::timerange '[:find ?t . :where [1 :timerange/timerange ?t]])
However, this "workaround" (for #41) is not going to work for us given that hardcoding IDs throughout our codebase is a non-starter.
Would you be open to receiving a PR that fixes either #41 or this issue? And if so, any pointers on where to start implementing them?
Sorry, something went wrong.
I found a workaround to the bug impeding this workaround. :)
If the initial db, rather than using the map form, uses instead the following (vector form), it works:
(def root-id 1) (def ^:private initial-db-state [[:db/add root-id (keyword "root" (name :timerange)) {:timerange "24h"}]])
It seems that :db/id in map form and explicit entity ID in vector form are divergent approaches w/ differing consequences.
Also, with this initial-db-state, I have the following function for constructing queries (which works from reg-query-sub):
(defn query-root-scalar [key] `[:find ?v# . :where [~root-id ~(keyword "root" (name key)) ?v#]])
No branches or pull requests
Suppose I have the following function to keep track of my singleton database IDs:
And this initial DB state:
Then the following query does not yield the correct result and instead gives the error "Tuple binding cannot be empty":
I also tried inlining the ID retrieval:
The text was updated successfully, but these errors were encountered: