mpdairy / posh

A luxuriously simple and powerful way to make front-ends with DataScript and Reagent in Clojure.
Eclipse Public License 1.0
460 stars 45 forks source link

Added support for tuples values on query :in or :where #38

Closed Quezion closed 4 years ago

Quezion commented 4 years ago

My understanding of the rules for differentiating lookup-refs:

;; ---- :where ----
;; All vectors in :where clause are values because lookup-refs are not allowed in them

;; ---- :in ----
;; Must look at query & understand how variable is being used in :where tuple
;; If variable used as 1st element (entity), always must be lookup-ref
;; If variable used as 3rd element (value), check attribute in schema for :db.valueType :db.type/ref
;; EX: :where [?e :foo ?v]
         :in ?v    = [:x 10]
;; -- check schema for :db/type of :foo, if not db.type/ref then it's a vector value

Fixes #37 , re-posh https://github.com/denistakeda/re-posh/issues/32

This also includes #31, which I rediscovered & fixed in the course of this PR.

Quezion commented 4 years ago

I definitely felt out of my depth working on this library -- but this solution satisfies the added tests on the Clojure side. I'm not sure how to run the tests on the CLJS side via cljsbuild.

There's need for a lot more tests. I could've broken something in the change to eav? -- it's a very simple "fix" & a better implementation might involve checking the :schema like resolve-any-idents does to look for :db.type/ref.

The reason I opened this PR is because I needed this changer to support my own re-frame based app. I'm going to release a sideband version of posh & re-posh off this library so I can continue with my own app development & I'll post back here with the updated dependency coordinates.

Quezion commented 4 years ago

I've published [org.clojars.questyarbrough/posh "0.5.7"] which includes this PR. It's working for my app though it's only exercising small set of DataScript's functionality.

Quezion commented 4 years ago

This functionality is included in pull-many PR https://github.com/mpdairy/posh/pull/39, so closing this PR. Can split PRs apart & reopen on request.