Search code examples
clojurecompojurenoir

Clojure warning: "resultset-seq already exists in clojure.core"


I'm new to Clojure and building a web app using the Noir framework (very similar to Compojure, in fact I think it's Compojure with a different request handler layer). I'm getting a warning when I import the JDBC library:

WARNING: resultset-seq already refers to: #'clojure.core/resultset-seq in namespace: webapp.models.database, being replaced by: #'clojure.java.jdbc/resultset-seq

Do I have to live with this warning or is there a way around it? I'm importing the JDBC library using:

(use 'clojure.java.jdbc)

Solution

  • You can avoid the problem by specifying the exact bindings to be imported:

    (use '[clojure.java.jdbc :only [insert-values transaction]])
    (transaction
      (insert-values ...))
    

    Another option is to :exclude the offending binding:

    (use '[clojure.java.jdbc :exclude [resultset-seq]])
    (transaction
      (insert-values ...))
    

    You can also just use require instead:

    (require '[clojure.java.jdbc :as db])
    (db/transaction
      (db/insert-values ...))
    

    With regard to forward compatibility, require is arguably safest. Using :only is just slightly less clean but still a pretty good approach (and easy to fix when it breaks). Excluding the currently offending bindings is probably the least future-proof way of fixing the problem since other conflicting bindings can appear at any time and tracking down what is imported from where can be tricky.