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

Feature/query extensions #4

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open

Conversation

egracer
Copy link
Contributor

@egracer egracer commented Oct 12, 2016

  1. Implemented IDeref on DatabaseComponent, which returns a datomic.db.Db instance.
  2. Updated the query function in untangled.datomic.core to support multiple data sources of varied types.

Anthony D'Ambrosio and others added 3 commits October 11, 2016 14:05
(let [param-type (type parameter)]
(cond
(= Db param-type) parameter
(contains? (supers param-type) Connection) (d/db parameter)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you have to use supers and contains??

Copy link
Contributor Author

@egracer egracer Oct 12, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It appears that instance? doesn't work for interfaces, only classes. Since Connection is an interface, it was the only approach that successfully identified the parameter as a datomic connection.

(swap! dbs conj parameter)
@parameter)
:else (or (some #(get (:seed-result %) parameter) @dbs) parameter))))]
(apply d/q query (map parse-parameter query-parameters)))))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should note (even just here) that this could be better parsed with clojure.spec.
Something like

(s/cat
   :dbs (s/+ (s/or :db database?, :conn connection?, :component component?))
   :seed-kws (s/+ (s/and keyword? #(= (namespace %) "datomic.id"))))
;; with some minor coercing of the dbs to all be a db after its conformed
;; and using the components to get the seed result

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, we'd have to modify :seed-kws to be more general because query parameters can be anything, but I like the idea of using clojure spec here.


(prefer-method io.aviso.exception/exception-dispatch clojure.lang.IPersistentMap clojure.lang.IDeref)
(prefer-method print-method clojure.lang.IRecord clojure.lang.IDeref)
(prefer-method clojure.pprint/simple-dispatch clojure.lang.IPersistentMap clojure.lang.IDeref)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these potentially harmful? Could it crash if somehow those deps are not available? Specifically io.aviso.exception.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought that you had added those in? Not sure what they are.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those multimethods are all for printing, and when I was testing deref it was failing to find a preferred method because IDeref messes up the hierarchy. I figured adding them wouldn't hurt, but I hadn't thought about the case when io.aviso.exception isnt a dependency.

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

Successfully merging this pull request may close these issues.

2 participants