datalevin

hrtmt brng 2025-07-17T15:16:52.867339Z

Do I make something wrong here? First ask for all attributes. The attribute :test/code-file is in that list. And then I ask for those entities, that have this attribute, and the result is empty.

((d/q '[:find ?attr
        :where
        [?x :type ut-table/test]
        [?x ?attr]]
      (d/db conn))
 [:test/code-file])
=> [:test/code-file]

(d/q '[:find ?x
       :where
       [?x :type ut-table/test]
       [?x :test/code-file]]
     (d/db conn))
=> #{}

hrtmt brng 2025-07-17T16:21:00.538559Z

I found out, that the problem has something to do with my schema. I think, I will be able to isolate the problem. Maybe it is just a stupid mistake, I am making. For some reason, this first query returns something even if ut-table/test is undefined.

hrtmt brng 2025-07-17T16:42:51.531569Z

To me it looks like a bug.

(def conn (d/get-conn "test/test_db"
                      {:my-type {:db/valueType :db.type/keyword}}))

(d/transact conn [{:my-type :ddd/test}])

(d/q '[:find ?x
       :where 
       [?x :my-type ddd/test]]
     (d/db conn))
=> #{[1]} ; should not work at all, or be empty, because I passed ddd/test instead of :ddd/test.
I looks like a feature. But then the following query should also work.
(d/q '[:find ?x
       :where 
       [?x :my-type :ddd/test]
       [?x :my-type ddd/test]]
     (d/db conn))
=> #{}

Huahai 2025-07-17T17:44:49.167729Z

the last query should not work, as it is saying the entity attribute having two different values.

hrtmt brng 2025-07-17T18:40:59.465749Z

Yes. But when you swap the two where clauses, then the last query works.

Huahai 2025-07-17T18:42:00.436699Z

interesting