jimpil / duratom

A durable atom type for Clojure
Eclipse Public License 1.0
213 stars 14 forks source link

compilation error on sql/with-db-transaction #4

Closed jaromil closed 6 years ago

jaromil commented 6 years ago

Nice idea! wanted to try duratom, but cannot build it into my project because of this compilation error below. I'm using Clojure 1.9:

Clojure.lang.Compiler$CompilerException: java.lang.RuntimeException: No such var: sql/with-db-transaction, compiling:(duratom/utils.clj:71:3)
             java.lang.RuntimeException: No such var: sql/with-db-transaction
jimpil commented 6 years ago

Hi there... This is strange! duratom does selective loading of backend-related mutator functions. For example, you can see in duratom.utils.clj the following snippet:

(try
  (require '[clojure.java.jdbc :as sql]) ;; attempt to load the proper ns
  (catch Exception e
    (require '[duratom.not-found.jdbc :as sql]))) ;; not-found  - load the dummy one

So basically, if clojure.java.jdbc is not found on the classpath, the dummy versions will be loaded (which throw exceptions when called). This is precisely done in order to avoid compilation errors like the one you're seeing. So I'm not sure what is the problem in your project...Could you elaborate a bit more on your project? How does your project.clj look like? Which duratom namespace are you requiring in your namespace?

I tried importing duratom 0.3.7 in another project of mine, picked up a random ns, and added this line: (:require [duratom.utils :as ut]). The namespace was loaded/compiled just fine, and i could call functions from it. If there was an issue with duratom I would have gotten the same exception as you. I didn't though, so I'm inclined to say that something is wrong with your code/project.

I'm happy to help out in resolving the issue, but first I'll need to reproduce it locally. If you can provide a minimal example/project that reproduces it, I'll jump straight on it. :)

jaromil commented 6 years ago

Thanks for your answer! I did notice the wrapper implementation in utils and was also wondering why it doesn't takes effect. So far I'm just sloppily trying stuff and have already deleted the test project, but I'll come back to this with more information on the next try as soon as I setup a new environment, meanwhile I guess I can close this issue.