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
Utilize protocol to get defaults (set-builder-fn, table-fn, label-fn and etc) #49
Comments
Given that protocols are based on types I don't see how this would work -- could you elaborate on what you have in mind? |
Sorry for not being clear. I propose to create a new protocol:
Then next-jdbc/src/next/jdbc/result_set.clj Line 407 in 6bc7164
And get default next-jdbc/src/next/jdbc/result_set.clj Line 424 in 6bc7164
builder-fn (get opts :builder-fn (p/builder-fn this)
If one wants to override it - he should A bit annoying, but doable. What do you think? |
Hm, not sure it works... |
I think you could base it on |
I'll play more with to ensure it actually works. Thanks! |
So you're thinking that the library would provide a default implementation for I still feel this is really hacky... |
I agree, feels hacky, but cant think of any other approach to override default behavior w/o global variable. |
I canvassed some of Clojure contributors and everyone who had an opinion felt this was a bad approach. Protocols should really only be extended either by the code that owns the protocol ( So I'm closing this out. My original suggestion of creating a wrapper API still stands -- but I think that should be in user code. |
I agree. Thanks for investigating it. |
Is your feature request related to a problem? Please describe.
It is pretty annoying to pass custom set-builder/table-fn/label-fn to every query or statement.
Describe the solution you'd like
It would help a lot if there would be a way to specify it only once.
But having the possibility to pass override via
opts
still important.Describe the solution you'd like
Maybe having a protocol to get defaults would help with this?
And if one wants to override defaults - it can be achieved with
extend-protocol
.Similar to
ReadableColumn
approach.The text was updated successfully, but these errors were encountered: