Hello everyone, I can't quite wrap my head around this result:
(let [db (d/db conn)]
(println (d/q '[:find ?u :where [?u :garden.user/name "sample-user"]] db))
(println (d/q '[:find ?u :where [?u :garden.user/name _]] db)))It outputs:
#{[3]}
#{}I simply don't understand how this is possible. Shouldn't the second result relation always be the same as or bigger than the first?
It appears the problem resolved itself... I don't know how I reached this state to begin with, but after clearing out the database completely and starting over it works as expected
I was just returning to this channel because it happened again... and yeah it seems like it happens on initial setup. What's the recommended version to revert to?
0.9.8 seems to work
Yeah 0.9.8 doesn’t have the issue. I tried looking into what the actual cause was but I’m out of depth. I’ve just got this commit checked out: 14502e772184a9564131e92575c554e724917be2 https://github.com/juji-io/datalevin/commit/14502e772184a9564131e92575c554e724917be2
Fixed in master
Sounds like it might be related to this issue https://github.com/juji-io/datalevin/pull/269
Amazing, I’ll switch to the latest master commit. 🚀
Ahh so count were not happening when a-size was zero. Did that cause the query planner just to ignore that attribute completely?
Right, the shortcut in the query processing will return nil immediately when some attributes found to have zero size.
Hello ppl! I encountered a weird problem about testids. Details are in thread.
I will try today. Fast attempt to isolate case yesterday failed :(
duckie
So… the rubber duck works. While trying to create an isolated case, I found out that there was an error in the :tariff/servers value, which is also a ref type with :db.cardinality/many. I had to include reverse lookups there.
However, the error message is a bit confusing, though…
What kind of error?
If it is something that the system should check for, we can add the check
I put in :tariff/servers such a vector like [:serv-1 :serv-2 ...etc...] , but :serv-1 and others are values of :server/id . I had to put reverse lookup there. So, the problem was that system complained about problems with transient maps, but better would be to say something like "Values in :tariff/servers have to be existent :tempid or reverse lookup clause, but found ':serv-1'"
ok, maybe file an issue so we can add such checks?
Error message:
Exception in thread "main" clojure.lang.ExceptionInfo: Unable to write transit:#error {
:cause "Not supported: class clojure.lang.PersistentArrayMap$TransientArrayMap"
:via
[{:type java.lang.RuntimeException
:message "java.lang.Exception: Not supported: class clojure.lang.PersistentArrayMap$TransientArrayMap"
:at [com.cognitect.transit.impl.WriterFactory$1 write "WriterFactory.java" 65]}
{:type java.lang.Exception
:message "Not supported: class clojure.lang.PersistentArrayMap$TransientArrayMap"
:at [com.cognitect.transit.impl.AbstractEmitter marshal "AbstractEmitter.java" 195]}]
:trace
[[com.cognitect.transit.impl.AbstractEmitter marshal "AbstractEmitter.java" 195]
[com.cognitect.transit.impl.JsonEmitter emitMap "JsonEmitter.java" 171]
[com.cognitect.transit.impl.AbstractEmitter emitMap "AbstractEmitter.java" 86]
[com.cognitect.transit.impl.AbstractEmitter marshal "AbstractEmitter.java" 185]
[com.cognitect.transit.impl.AbstractEmitter marshalTop "AbstractEmitter.java" 212]
[com.cognitect.transit.impl.JsonEmitter emit "JsonEmitter.java" 41]
[com.cognitect.transit.impl.WriterFactory$1 write "WriterFactory.java" 62]
[cognitect.transit$write invokeStatic "transit.clj" 171]
[datalevin.protocol$write_transit_string invokeStatic "protocol.clj" 45]
[pod.huahaiy.datalevin$run$fn__28160 invoke "datalevin.clj" 896]
[pod.huahaiy.datalevin$run invokeStatic "datalevin.clj" 878]
[datalevin.main$_main invokeStatic "main.clj" 527]
[datalevin.main$_main doInvoke "main.clj" 513]
[clojure.lang.RestFn invoke "RestFn.java" 397]
[clojure.lang.AFn applyToHelper "AFn.java" 152]
[clojure.lang.RestFn applyTo "RestFn.java" 132]
[datalevin.main main nil -1]]} {:value {:error :transact/syntax, :tempids #object[clojure.lang.PersistentArrayMap$TransientArrayMap 0x54507296 "clojure.lang.PersistentArrayMap$TransientArrayMap@54507296"], :type "class clojure.lang.ExceptionInfo"}}
at datalevin.protocol$write_transit_string.invokeStatic(protocol.clj:52)
at pod.huahaiy.datalevin$run$fn__28160.invoke(datalevin.clj:896)
at pod.huahaiy.datalevin$run.invokeStatic(datalevin.clj:878)
at datalevin.main$_main.invokeStatic(main.clj:527)
………
Data passed to d/transact!:
[{:db/id -1, :price/amount {:months 1}, :price/price 100M}
{:db/id -2, :price/amount {:months 6}, :price/price 500M}
{:db/id -3, :price/amount {:years 1}, :price/price 800M}
{:tariff/description "Test 1",
:tariff/id :test,
:tariff/name "Test",
:tariff/prices [-1 -2 -3],
:tariff/priority 0,
:tariff/servers ["srv-1"],
:tariff/type :date}]}
The :tariff/prices attribute is of :db.type/ref and :db.cardinality/many
Sure I checked many times that no any transient collection appears in my data. But if I try to run simple transaction like this, it works fine:
(comment
(require '[pod.huahaiy.datalevin :as d]
'[babashka.fs :as fs])
(let [dtlv-dir (str "/tmp/dtlv-sandbox-" (random-uuid))
conn (d/get-conn dtlv-dir {:a/x {:db/valueType :db.type/long}
:a/y {:db/valueType :db.type/keyword}
:b/as {:db/valueType :db.type/ref
:db/cardinality :db.cardinality/many}})]
(try
(d/transact! conn [{:db/id -1
:a/x 1 :a/y :a1}
{:db/id -2
:a/x 2 :a/y :a2}
{:db/id -3
:a/x 3 :a/y :a3}
{:b/as [-1 -2 -3]}])
(d/q '[:find (pull ?b [* {:b/as [*]}])
:where [?b :b/as]] (d/db conn))
(finally
(d/close conn)
(fs/delete-tree dtlv-dir)))))
So… what could be a problem?tempids collection is transient. so some error in the transaction logic
somewhere in the db.clj
could you isolate a test case?