Fork me on GitHub
#om
<
2017-02-04
>
mjhamrick01:02:18

In om-next, is a mutate function supossed to be able to return {:value nil}?

levitanong06:02:42

@mjhamrick afaik, the :value key only helps you document what keys are involved with the mutation, but doesn’t actually do anything.

alex-glv11:02:42

Hey guys, what are the first things to look into when my data is not normalized coming from remote? I made sure that state is not in an atom, and ident is implemented.. A bit baffled as to why one subquery is normalized but not the other, even though they’re quite similar.

alex-glv12:02:16

… The only difference I think could be made by the fact that it’s a parametrized query

qqq16:02:35

is there a larger demo than https://github.com/omcljs/om/wiki/DataScript-Integration-Tutorial on datascript <-> om.next ?

tony.kay17:02:51

@alex-glv Normalization works because the get-query function puts metadata on the query indicating which component it goes with. If you use a query that isn't properly annotated with metadata then normalization will break. So, I'd guess you're doing something funky with your parameterization? Perhaps putting in a bit of subquery as raw data instead of pulling it from the query of a component with an ident?

drcode17:02:31

@qqq only datascript<->om example I'm aware of

nha21:02:30

@sineer I have been looking for that 🙂 Thanks for sharing!

alex-glv22:02:11

@tony.kay: thanks for the tip; I am not touching query metadata, but am passing params later in the parsing stage. I'll check if there's anything that can affect it. Also, I am using query-root in ast to set remote query root, but I can't see why it'd make any difference.

alex-glv23:02:51

@tony.kay I implemented homebrew router, and my root query was something like {:root/data [{:route1 (om/get-query route1class) :route2 (om/get-query route2class)}]} Then later in the parsing I did: (get query current-route) So normalization worked for the route1, but nor route2, even though after parsing the query there left only one join query. I replaced the root query to be joins for all routes: {:root/data [{:route1 (om/get-query route1class)} {:route2 …}} and then filter out only active route join query. And that fixed it. So, normalization works based off what your query is in the component, not what you return after parsing.

anmonteiro23:02:29

@alex-glv: that's a rather premature conclusion to make

anmonteiro23:02:27

The first query you pasted is incorrect

anmonteiro23:02:01

A join should only have 1 key/value pair; yours has 2

alex-glv23:02:55

Yeah absolutely, the root query was incorrect, that was the cause of the issue. My conclusion was that even if you parse the query in (defmethod read :root/data) return ast for it that contains valid join (that is, all key/value pairs that are not related to the current route gone) the normalization breaks.

alex-glv23:02:24

In other words, queries on components should be correct and not incorrect… :face_with_rolling_eyes: