This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-10-21
Channels
- # 100-days-of-code (5)
- # announcements (6)
- # beginners (92)
- # cider (39)
- # cljdoc (35)
- # cljsrn (1)
- # clojure (187)
- # clojure-sanfrancisco (2)
- # clojure-spec (26)
- # clojure-sweden (2)
- # clojure-uk (1)
- # clojurescript (27)
- # cursive (19)
- # datascript (3)
- # datomic (19)
- # defnpodcast (1)
- # emacs (11)
- # fulcro (71)
- # incanter (1)
- # lein-figwheel (4)
- # lumo (10)
- # off-topic (19)
- # planck (5)
- # reagent (49)
- # reitit (2)
- # shadow-cljs (25)
- # spacemacs (1)
- # sql (1)
- # unrepl (4)
- # yada (4)
ok.. I have a pretty weird problem. I have some ion code that runs a query and i'm getting different behavior on the server vs running the same code locally via a repl. I've done all sorts of testing, dumped my params map to a string, edn parsed it and re-run the same code in the repl, dumped the param types to make sure that nothing weird was happening there, but so far, again, calling the exact same function (which just calls a query and flattens the result) with the exact same parameters is behaving differently on the server (incorrectly) vs the client Ok, I think this might be a bug. I noticed I had some other code with virtually the same query, that wasn't exhibiting the same behavior. Ultimately the only difference between the two was that the one that is misbehaving was only returning a bound entity id, where the other was using it in a pull such that basically
; returns seq of ids on client, empty seq on server for exact same :where, params, etc
(d/q '[:find ?o ...
; as expected identical behavior on client and server
(d/q '[:find (pull ?o [...])...
; working around the first with something like following works fine
(->>
(d/q '[:find (pull ?o [:db/id])...
flatten
(map :db/id)
@U1QJACBUM did you guys see this?
@U380J7PAQ Hey! Just saw this. I am not sure I am following you on the use of “client” and “server” here. Are you saying that you are noticing a different behavior between invoking a query on Ions and a local repl? Or, are you referring to a difference between on-prem/peer-server and client? Do you have a full gist showing what you’re running and where?
sorry I wasn't clear. Yes, that's exactly it. Seeing this behavior in local REPL, tunneled to server, vs on the server itself.
Ok so if I write some queries as above and invoke them with query and connected directly to the stack via REPL I should see different behavior?
yeah that's what I was seeing. Here's the actual full code
(defn get-all-results
[db {:keys [run/number primer-pair/pair-id sample/extid customer/cust-id]
:as params}]
(cast/event {:msg "get-all-results"
::params [number pair-id extid cust-id]
})
(->>
(d/q '[:find #_?o (pull ?o [:db/id])
:in $ ?run-num ?pp ?samp-id ?cust-id
:where
[?r :run/number ?run-num]
[?p :primer-pair/pair-id ?pp]
[?s :sample/extid ?samp-id]
[?u :customer/samples ?s]
[?u :customer/cust-id ?cust-id]
[?o :otuabund/run ?r]
[?o :otuabund/primer-pair ?p]
[?o :otuabund/sample ?s]
]
db number pair-id extid cust-id)
flatten
(map :db/id))
)
because it was being called from an API and what have you. so wanted to get that out of the loop. But once I got it stripped down, the pull version worked, if I pushed the one that just returned the id it failed
totally inconsequential because it's not used, but there's a typo in the Datomic/ion-starter
example. https://github.com/Datomic/ion-starter/blame/master/src/datomic/ion/starter.clj#L97 "contect" should be "context"? I tried to create a PR but i don't think they're accepted upstream so dropping a note here. 🙂