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

Ignores functions used inside 'extend-protocol' #41

Open
thisdotrob opened this issue Jun 19, 2018 · 0 comments
Open

Ignores functions used inside 'extend-protocol' #41

thisdotrob opened this issue Jun 19, 2018 · 0 comments

Comments

@thisdotrob
Copy link

thisdotrob commented Jun 19, 2018

For the following code, both ISO-date-format and java->joda-local-date are flagged as being unused.

(def ISO-date-format
  (tf/formatter "yyyy-MM-dd"))

(defn java->joda-local-date [java-local-date]
    (tf/parse-local-date ISO-date-format (.toString java-local-date)))

;; Prevent default behaviour of coercing sql-dates into clojure instants. A date in our database refers to a calendar day, not a moment in time, and coercing to an instant in time brings all manner of silly painful bugs.
;; https://dev.clojure.org/jira/browse/JDBC-35 for more details
(extend-protocol jdbc/IResultSetReadColumn
  java.sql.Date
  (result-set-read-column [val _ _]
    (java->joda-local-date (.toLocalDate val)))

  java.sql.Timestamp
  (result-set-read-column [val _ _]
    (.toInstant val))

  org.postgresql.jdbc4.Jdbc4Array
  (result-set-read-column [pgobj _ _]
    (vec (.getArray pgobj)))

  org.postgresql.util.PGobject
  (result-set-read-column [pgobj _ _]
    (if (= (.getType pgobj) "json")
      (json/read-str (.toString pgobj)
                     :key-fn (comp keyword name dbh/snake-case->kebab-case))
      pgobj)))
@thisdotrob thisdotrob changed the title Ignores functions used inside extend-protocol Ignores functions used inside 'extend-protocol' Jun 19, 2018
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

No branches or pull requests

1 participant