datascript

Oliver Marks 2025-03-13T13:44:31.106369Z

I am experiencing a very strange problem I can't explain, my query is failing to find the entity in the database.

(defn fetch-plant-eid-from-uuid [uuid]
  (prn (str "fetch plant from uuid " uuid))
  (prn @diag)
  (prn (d/q '{:find [?plant]
               :in [$ ?uuid]
               :where [[?plant :plant/id ?uuid]]} @diag "b0247752-5eab-4987-8116-78d43dcf9b04"))

  (prn (d/q '{:find [?plant]
               :where [[?plant :plant/id "b0247752-5eab-4987-8116-78d43dcf9b04"]]} @diag )))
If you look at the first query which passes in the uuid as a string it fails to find the entity, the second query which has the uuid in-lined inside the query does work, which see very strange to me anyone got any pointers on what might be going on (edited)

Niki 2025-03-13T14:13:22.736429Z

should be identical

Niki 2025-03-13T14:13:46.511789Z

If you can make a reproduceable test case feel free to open an issue

Oliver Marks 2025-03-13T14:18:23.947099Z

That was my thinking which is why I am a bit confused, I have other queries I am running which are working fine, I have also noticed it seems to work locally it only after deployment with shadow cljs so I guess it could be related to the optimizations in some way, I will carry on digging I imagine replicating it will be quite difficult. probably I will just change to inlining the value if I don't get any where

Niki 2025-03-13T15:09:06.489919Z

Do you provide externs to shadow?

Niki 2025-03-13T15:09:14.223779Z

That has been a source of so many bugs

Oliver Marks 2025-03-14T10:37:38.288399Z

Thanks @tonsky For the suggestion I have this :compiler-options {:infer-externs :auto :output-feature-set :es6} which I thought should be sufficient or should I be more explicit ?

Oliver Marks 2025-03-14T10:59:04.595899Z

I added in the externs and that seems to have resolved it so you where correct in that assumption thanks again πŸ™‚

πŸ‘ 1
Niki 2025-03-14T14:51:22.239939Z

Glad it helped. I tried to convince them shadow should respect externs that come with a library but they don’t want to listen