Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

full-query thinks "No queries exist" when the query path includes a link #773

Closed
Peeja opened this issue Sep 18, 2016 · 1 comment
Closed

Comments

@Peeja
Copy link

Peeja commented Sep 18, 2016

Consider a component whose query path includes a link, such as an instance of IdxrLinkItem from the tests:

(defui IdxrLinkItem
  static om/IQuery
  (query [this]
    [:b]))

(defui IdxrLinkRoot
  static om/IQuery
  (query [this]
    [{[:a '_] (om/get-query IdxrLinkItem)}]))

Its query will be [{[:a _] [:b]}], and it will be indexed as such. However, its path will be [:a :b]. This means that it will fail to match when full-query looks up the query in the indexer.


(deftest test-full-query
  (testing "OM-773: `full-query` thinks no queries exist when the query path includes a link"
    (let [r (om/reconciler
             {:state (atom nil)
              :parser (om/parser {:read (fn [_ _ _] {})})})
          idxr (get-in r [:config :indexer])
          _ (p/add-root! r IdxrLinkRoot nil nil)
          _ (p/index-component! idxr #?(:clj (IdxrLinkRoot nil nil #js {:omcljs$reconciler r} nil)
                                        :cljs (IdxrLinkRoot. #js {:omcljs$reconciler r})))
          root (-> @idxr :class->components (get IdxrLinkRoot) first)
          child #?(:clj (IdxrLinkItem nil nil #js {:omcljs$reconciler r
                                                   :omcljs$path [:a]
                                                   :omcljs$parent root} nil)
                   :cljs (IdxrLinkItem. #js {:omcljs$reconciler r
                                             :omcljs$path [:a]
                                             :omcljs$parent root}))
          _ (p/index-component! idxr child)]
      (is (= (om/full-query child)
             '[{[:a _] [:b]}])))))
@Peeja Peeja changed the title :class-path->query can contain links full-query thinks "No queries exist" when the query includes a link Sep 18, 2016
@Peeja Peeja changed the title full-query thinks "No queries exist" when the query includes a link full-query thinks "No queries exist" when the query path includes a link Sep 18, 2016
@anmonteiro
Copy link
Contributor

fixed 99862b2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants