Fork me on GitHub
#xtdb
<
2021-10-09
>
tianshu10:10:32

No sure if it's a bug or not, if a document's id is URL, it can't be queried through xt/q, can only be found through xt/entity ?

tianshu10:10:49

change the id type from URL to string, everything works fine.

malcolmsparks10:10:10

I'm not sure that's right. Do you have an example query? Are you expecting a coercion to occur?

tianshu10:10:39

wait a moment, I'm writing a reproduce example

👍 1
tianshu10:10:52

start xtdb node with this function, found in the tutorial

(defn start-xtdb!
  []
  (letfn [(kv-store [dir]
                    {:kv-store {:xtdb/module 'xtdb.rocksdb/->kv-store,
                                :db-dir      (io/file dir),
                                :sync?       true}})]
    (xt/start-node
     {:xtdb/tx-log         (kv-store "data/dev/tx-log"),
      :xtdb/document-store (kv-store "data/dev/document-store"),
      :xtdb/index-store    (kv-store "data/dev/index-store")})))
and the code and output
(->> (xt/submit-tx @node [[::xt/put {:xt/id (URL. "") :a/b 1}]])
     (xt/await-tx @node))
;; => #:xtdb.api{:tx-time #inst "2021-10-09T10:17:02.304-00:00", :tx-id 0}

(->> (xt/submit-tx @node [[::xt/put {:xt/id "xyz" :a/b 1}]])
     (xt/await-tx @node))
;; => #:xtdb.api{:tx-time #inst "2021-10-09T10:17:04.240-00:00", :tx-id 1}

(xt/entity (xt/db @node) (URL. ""))
;; => {:a/b 1, :xt/id #object[java.net.URL 0x10157555 ""]}

(xt/entity (xt/db @node) "xyz")
;; => {:a/b 1, :xt/id "xyz"}

(xt/q (xt/db @node) '{:find [?e] :where [[?e :a/b 1]]})
;; => #{["xyz"]}

malcolmsparks10:10:58

Thanks. That doesn't look right to me either. Really helpful to have this failing case. Could you paste this to a new issue on github?

refset20:10:29

Hi @U0NBGRGD6 I am able to reproduce this and it looks like a bug to me - sorry about that, but thank you for reporting it. Are you able to use URIs instead? I just checked that URIs work as expected

tianshu15:10:27

Didn't touch my computer in this week, glad to know there's an issue for the problem. nice job!!

🙂 1
🙏 1
refset16:10:52

> Didn't touch my computer in this week Sounds like a nice week 😄

tianshu10:10:24

I was expecting there are 2 entities found

tianshu10:10:26

The version I'm using

com.xtdb/xtdb-core             {:mvn/version "1.19.0-beta1"},
com.xtdb/xtdb-rocksdb          {:mvn/version "1.19.0-beta1"},