-
Notifications
You must be signed in to change notification settings - Fork 2
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
base: develop
Are you sure you want to change the base?
Conversation
…db from the connection
- core/query supports Connections and DatabaseComponents as sources
(let [param-type (type parameter)] | ||
(cond | ||
(= Db param-type) parameter | ||
(contains? (supers param-type) Connection) (d/db parameter) |
There was a problem hiding this comment.
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?
?
There was a problem hiding this comment.
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))))) |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
untangled.datomic.core
to support multiple data sources of varied types.