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

Odd interaction with xtdb #66

Open
nivekuil opened this issue May 15, 2022 · 2 comments
Open

Odd interaction with xtdb #66

nivekuil opened this issue May 15, 2022 · 2 comments

Comments

@nivekuil
Copy link

nivekuil commented May 15, 2022

(def test-node (xt/start-node {}))
(xt/submit-tx test-node [[::xt/put {:xt/id {:foo "1"}}]])

;; correctly returns the entity
(xt/entity (xt/db test-node) {:foo "1"})

;; returns nil?!
(y/? (y/sp (xt/entity (xt/db test-node) {:foo "1"})))
  

This only seems to happen when the :xt/id is a map, so it could be something odd on the XTDB side as well. Any ideas? repro: https://github.com/nivekuil/missionary-xtdb-repro java version is 17 (graalvm), clojure 1.11.1

@leonoel
Copy link
Owner

leonoel commented May 16, 2022

The issue seems related to type hints. sp tags forms with inferred types, confusing xtdb somehow. Here is a xtdb-only minimal repro :

;; incorrectly returns nil
(xt/entity (xt/db test-node) ^clojure.lang.PersistentArrayMap {:foo "1"})

A possible workaround could be to move the eid outside of the sp block to prevent tagging :

;; correctly returns the entity
(def eid {:foo "1"})
(y/? (y/sp (xt/entity (xt/db test-node) eid)))

@nivekuil
Copy link
Author

nivekuil commented May 16, 2022

Ah, I think I know what problem it is.. xtdb's nippy usage takes into account metadata so that type hint actually changes the document key for that entity. Reported previously here xtdb/xtdb#1510. It's definitely a problem on xtdb's end, not sure there is anything to do for missionary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants