korma / Korma

Tasty SQL for Clojure.
http://sqlkorma.com
1.48k stars 222 forks source link

Allow korma to specify extra parameters to defdb #373

Open mprokopov opened 7 years ago

mprokopov commented 7 years ago

I faced to following issue with local timezone using mysql http://stackoverflow.com/questions/26515700/mysql-jdbc-driver-5-1-33-time-zone-issue

And I did some workaround for that:

(def db-params (mysql {:host "localhost"
                      :db "itservice"
                      :user "root"}))

(def extra-params {:useLegacyDatetimeCode false
               :serverTimezone "UTC"
               :useSSL false})

(def subparams (->> (map (fn [[k v]] (str (name k) "=" v)) extra-params)
                (clojure.string/join "&")
                (str "?")))
(def new-params (update db-params :subname #(str % subparams)))
(defdb my-db new-params)

so params string should look something like "//localhost:3306/itservice?useLegacyDatetimeCode=false&serverTimezone=UTC&useSSL=false", and there is no support for such extra parameters for db-params.

ls4f commented 7 years ago

Will mysql accept those extra parameters as properties (instead of URL params)? Korma does pass on any extra keys you might've set to the data source.

mprokopov commented 7 years ago

I've created pull request for proper support of extra parameters.

https://github.com/korma/Korma/pull/374

ls4f commented 7 years ago

While I'm not a maintainer, if the functionality is needed (some drivers might indeed require options be set via the URL), it seems better to handle it in defdb and make it work for any and all possible databases.

venantius commented 6 years ago

I've commented on your PR, but I appreciate that both it and this issue are quite old.

Is this still a priority issue?

If there hasn't been a response to this issue in 2 weeks, I'll close the ticket.

Janderio commented 6 years ago

I had the same problem (timezone) until configure the server correct, the parameters would be great addition if possible to work even if you can't access the servers config.