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

Pull queries do not update if their nested entities change #26

Open
seantempesta opened this issue Apr 30, 2017 · 6 comments

Comments

Projects
None yet
3 participants
@seantempesta
Copy link

commented Apr 30, 2017

Ran into this bug today. I had a (pull conn '[*] eid) that wasn't updating when a nested entity within that pull changed. I'm guessing it's because the datom match pattern is just for the specified eid (and not all returned entities)?

Anyway, I setup an example showing the bug here:
https://github.com/seantempesta/posh-bug

The jist of it is this:

(def schema {;; Contact component (shared across entities)
             :contact/email {:db/cardinality :db.cardinality/one}
             :contact/phone {:db/cardinality :db.cardinality/one}

             ;; Users
             :user/username {:db/unique      :db.unique/identity
                             :db/cardinality :db.cardinality/one}
             :user/contact  {:db/valueType   :db.type/ref
                             :db/cardinality :db.cardinality/one
                             :db/isComponent true}})
(def conn (d/create-conn schema))
(posh! conn)


(transact! conn [{:db/id         -1
                  :user/username "seantempesta"
                  :user/contact  {:db/id         -2
                                  :contact/phone "555-5555"
                                  :contact/email "sean.tempesta@gmail.com"}}])



;; -------------------------
;; Views

(defn home-page []
  (let [user (pull conn '[*] [:user/username "seantempesta"])
        phone (pull conn '[*] 2)]
    [:div [:h2 "Welcome to posh-bug!"]

     [:div [:h4 {} "User Entity"]
      [:h5 {} @user]]

     [:div [:h4 {} "Phone Entity"]
      [:h5 {} @phone]]

     [:input {:type     "button" :value "Remove phone number"
              :on-click #(transact! conn [[:db/retract 2 :contact/phone "555-5555"]])}]]))

screen shot 2017-04-30 at 11 44 37 am

@seantempesta

This comment has been minimized.

Copy link
Author

commented May 22, 2017

So, I'm really not familiar enough with Posh's internals to fix this. I thought I saw somewhere that Posh might bring back manual specification of listen patterns? At least then I could work around this bug.

@seantempesta

This comment has been minimized.

Copy link
Author

commented May 22, 2017

Temporary workaround. I found if you explicitly expand isComponent pull patterns the pull analyze picks up the changes.

So, in the example above, you'd have to do something like this:

(pull conn '[:db/id, :user/username, {:user/contact [:db/id, :contact/email, :contact/phone]}] 2)
@metasoarous

This comment has been minimized.

Copy link
Collaborator

commented May 22, 2017

Yes; it should certainly be looking at isComponent attributes. I'm flagging as bug. Thanks for reporting.

@eoliphan

This comment has been minimized.

Copy link

commented Nov 30, 2017

@seantempesta was that all you had to do? I've tried the explicit expansion, still no joy for my reactions

@seantempesta

This comment has been minimized.

Copy link
Author

commented Nov 30, 2017

@eoliphan: It worked for my scenario at that time. No idea if it's working now as I'm no longer using Posh.

@eoliphan

This comment has been minimized.

Copy link

commented Nov 30, 2017

@seantempesta ok, thanks. Yeah, i'm looking at alternatives as well, I really wanted to use DS as I've got Datomic on the server, but probably will just go with specter and maps, etc. for now until I can maybe look at figuring out the posh code and doing some hacking.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.