This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-06-23
Channels
- # announcements (16)
- # asami (4)
- # babashka (49)
- # beginners (70)
- # calva (25)
- # clojars (3)
- # clojure (40)
- # clojure-europe (82)
- # clojure-france (15)
- # clojure-gamedev (16)
- # clojure-nl (2)
- # clojured (7)
- # clojurescript (13)
- # conjure (11)
- # cursive (4)
- # data-science (12)
- # datalevin (2)
- # figwheel-main (5)
- # gratitude (5)
- # honeysql (5)
- # hyperfiddle (4)
- # jobs (4)
- # joyride (3)
- # lsp (10)
- # malli (2)
- # missionary (14)
- # nbb (2)
- # off-topic (3)
- # pathom (16)
- # rdf (5)
- # releases (4)
- # sci (35)
- # shadow-cljs (16)
- # tools-deps (22)
- # xtdb (7)
user> (xt/submit-tx node [[::xt/put {:xt/id "test1" :foo 1}]
[::xt/put {:xt/id "test2" :foo nil}]
[::xt/put {:xt/id "test3" :foo {:bar 42}}]])
;; order by will crash if result has maps
user> (xt/q (xt/db node) '{:find [e v] :where [[e :foo v]] :order-by [[v :asc]]})
Execution error (ClassCastException) at xtdb.query$order_by_comparator$reify__56976/compare (query.clj:1682).
class clojure.lang.PersistentArrayMap cannot be cast to class java.lang.Comparable (clojure.lang.PersistentArrayMap is in unnamed module of loader 'app'; java.lang.Comparable is in module java.base of loader 'bootstrap')
;; nil order works
user> (xt/q (xt/db node) '{:find [e v] :where [[e :foo v]] :order-by [[v :asc]] :in [[e ...]]} ["test1" "test2"])
[["test2" nil] ["test1" 1]]
I know clojure maps aren’t sortable, but should the query throw or return something?I guess in most application purposes you can know (if not guarantee) that the result will not have maps
but just noticed that in my XTDB inspector use case which doesn’t know anything about the values, the attr values page will crash… I need to move the sorting to after the query and do it by string representations
Hm, but it can cause nasty bugs when there is no schema and nothing can prevent another place from putting a new document that breaks old code
That is, I think that if the query is valid, it should never throw (unless the engine is in a broken state or something), and an invalid query should always fail
Thanks for the good discussion and I agree that this is a bug that needs fixing. It's in a similar vein to https://github.com/xtdb/xtdb/issues/1710. I've just opened a new issue: https://github.com/xtdb/xtdb/issues/1775